add enums for attack types, add angle calc

This commit is contained in:
tonydero 2024-10-16 15:04:44 -06:00
parent 1496610364
commit a0cef620e0

View File

@ -2,12 +2,15 @@
class_name AbilityPlayer
extends TextureRect
enum TARGTYPES { SINGLE, CLEAVE, CHAIN, SWIPE, WAVE, AREA, RAY }
enum PDMGTYPES { SLICE, PUNCTURE, BASH, HACK, SHRED }
enum MDMGTYPES { BURN, FREEZE, SHOCK, POISON, LIFE, RADIANT, ARCANE, FORCE }
var middleX
var playerPos
@export var attack_range := 0
@export var attack_type := "single_target"
@export var attack_type := TARGTYPES.SINGLE
@export var attack_damage := 200
@export var attack_speed := 1.0
@ -31,17 +34,21 @@ func _get_num_enemies() -> int:
return enemies.size()
func _get_distance_to_player(enemy: Node) -> float:
func _get_distsq_to_player(enemy: Node) -> float:
return enemy.position.distance_squared_to(playerPos)
func _get_angle_to_player(enemy: Node) -> float:
return enemy.position.angle_to_point(playerPos)
func _get_target(enemies) -> Node:
# var numEnemies := _get_num_enemies()
# TODO implement range, i.e. closest within range
var enemyDists
var closestEnemy
# get list of distances by mapping distance to each node in enemies
enemyDists = enemies.map(_get_distance_to_player)
enemyDists = enemies.map(_get_distsq_to_player)
# get closest enemy by finding first index with min dist
closestEnemy = enemies[enemyDists.find(enemyDists.min())]