Implement attack_limit for Unit

This commit is contained in:
CactiChameleon9 2022-03-15 13:13:44 +00:00
parent 1d30a03966
commit 15b477ca71

View File

@ -6,6 +6,7 @@ export var unit_type : String
export var max_health : int = 10 export var max_health : int = 10
export var health : int = 10 export var health : int = 10
export var movement_distance : int = 10 export var movement_distance : int = 10
export var attack_limit : int = 20
export var height : int = 0 export var height : int = 0
export var water_walk : bool = false export var water_walk : bool = false
export var air_walk : bool = false export var air_walk : bool = false
@ -26,7 +27,7 @@ onready var Grid = get_node("../Grid")
func start_turn(): func start_turn():
attack_points = 0 attack_points = attack_limit
movement_points = movement_distance movement_points = movement_distance
_has_sent_turn_completed = false _has_sent_turn_completed = false
@ -77,7 +78,7 @@ func move(movement : Vector2):
z_index = 100 z_index = 100
func attack(damage : float, points : int, pattern : PoolVector2Array): #TODO func attack(damage : int, points : int, pattern : PoolVector2Array): #TODO
if attack_points != 0: if attack_points != 0:
#change animation to attacking #change animation to attacking
$AnimationPlayer.play("Attack front") $AnimationPlayer.play("Attack front")
@ -105,8 +106,6 @@ func _physics_process(delta: float) -> void:
position.x = move_toward(position.x, _target_position.x, 800 * delta) position.x = move_toward(position.x, _target_position.x, 800 * delta)
position.y = move_toward(position.y, _target_position.y, 800 * delta) position.y = move_toward(position.y, _target_position.y, 800 * delta)
attack_points = false
if attack_points == 0 && movement_points == 0 && not _has_sent_turn_completed: if attack_points == 0 && movement_points == 0 && not _has_sent_turn_completed:
emit_signal("turn_completed") emit_signal("turn_completed")
_has_sent_turn_completed = true _has_sent_turn_completed = true