2024-10-25 15:41:39 +08:00
|
|
|
extends ActionLeaf
|
|
|
|
|
|
|
|
|
|
|
|
func tick(actor:Node,black_board:Blackboard):
|
|
|
|
var unit:Unit=actor
|
|
|
|
if unit.is_attacking():
|
|
|
|
var target_unit:Unit=Global.get_unit_instance(black_board.get_value("target_unit_id"))
|
2024-10-25 17:45:08 +08:00
|
|
|
if is_instance_valid(target_unit):
|
|
|
|
unit.set_target(target_unit.global_position)
|
2024-10-25 15:41:39 +08:00
|
|
|
return RUNNING
|
|
|
|
if unit.is_attack_finished():
|
|
|
|
black_board.erase_value("target_unit_id")
|
2024-10-26 22:17:29 +08:00
|
|
|
match unit.get_dir():
|
|
|
|
0:
|
|
|
|
unit.play_animation("up_idle")
|
|
|
|
1:
|
|
|
|
unit.play_animation("down_idle")
|
|
|
|
2:
|
|
|
|
unit.play_animation("left_right_idle")
|
|
|
|
3:
|
|
|
|
unit.play_animation("left_right_idle")
|
|
|
|
unit.attack_reset()
|
2024-10-25 15:41:39 +08:00
|
|
|
return SUCCESS
|
|
|
|
if black_board.has_value("target_unit_id") and not unit.is_attacking():
|
|
|
|
unit.attack()
|
|
|
|
var target_unit:Unit=Global.get_unit_instance(black_board.get_value("target_unit_id"))
|
|
|
|
unit.set_target(target_unit.global_position)
|
|
|
|
return RUNNING
|