Add attack and attacked method to Unit
This commit is contained in:
parent
25a400f31f
commit
1d30a03966
@ -68,7 +68,6 @@ func move(movement : Vector2):
|
|||||||
var area_around = Grid.get_around_coordinate(Grid.position_to_coordinates(position, height), i)
|
var area_around = Grid.get_around_coordinate(Grid.position_to_coordinates(position, height), i)
|
||||||
if not area_around.has(Grid.position_to_coordinates(_target_position, _target_height)):
|
if not area_around.has(Grid.position_to_coordinates(_target_position, _target_height)):
|
||||||
movement_points = movement_points - i - 1
|
movement_points = movement_points - i - 1
|
||||||
print(movement_points)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
#change the z_index
|
#change the z_index
|
||||||
@ -78,13 +77,27 @@ func move(movement : Vector2):
|
|||||||
z_index = 100
|
z_index = 100
|
||||||
|
|
||||||
|
|
||||||
func attack(): #TODO
|
func attack(damage : float, points : int, pattern : PoolVector2Array): #TODO
|
||||||
if attack_points == 0:
|
if attack_points != 0:
|
||||||
#change animation to attacking
|
#change animation to attacking
|
||||||
#make attacked change to hurt animation
|
$AnimationPlayer.play("Attack front")
|
||||||
#somehow change health values
|
|
||||||
#maybe using an attacked method??
|
#selects all of the units within the attack pattern
|
||||||
attack_points = 0
|
# and calls their attacked method
|
||||||
|
for i in range(pattern.size()):
|
||||||
|
var coord = Grid.position_to_coordinates(position, height)
|
||||||
|
var selected_name = Grid.grid[coord.x + pattern[i].x][coord.y + pattern[i].y][0]
|
||||||
|
if selected_name:
|
||||||
|
get_node(("../" + selected_name)).attacked(damage, "") #TODO effects implementation
|
||||||
|
|
||||||
|
#change the attack points left
|
||||||
|
attack_points = max(attack_points - points, 0) #keep >= 0
|
||||||
|
|
||||||
|
|
||||||
|
func attacked(damage : float, effects : String):
|
||||||
|
$AnimationPlayer.play("Attacked front")
|
||||||
|
health -= damage
|
||||||
|
#probably do some stuff here TODO with death
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
Loading…
Reference in New Issue
Block a user