RockyWrench.gd 861 B

1234567891011121314151617181920212223242526272829303132333435
  1. extends Enemy
  2. @export var can_stomp := false
  3. const WRENCH_PROJECTILE = preload("uid://p42vcj0qmhxl")
  4. var count := 0
  5. func _ready() -> void:
  6. $Timer.start()
  7. func on_player_stomped_on(player: Player) -> void:
  8. if can_stomp:
  9. $GibSpawner.stomp_die(player)
  10. func on_timeout() -> void:
  11. if is_on_floor() == false:
  12. return
  13. direction = sign(get_tree().get_first_node_in_group("Players").global_position.x - global_position.x + 1)
  14. $Sprite.scale.x = direction
  15. if count == 0:
  16. $Animations.play("PeekOut")
  17. $Sprite.play("Idle")
  18. else:
  19. count = -1
  20. $Sprite.play("Aim")
  21. $Animations.play("Throw")
  22. await $Animations.animation_finished
  23. $Timer.start()
  24. count += 1
  25. func throw_wrench() -> void:
  26. $Sprite.play("Throw")
  27. var node = WRENCH_PROJECTILE.instantiate()
  28. node.global_position = $Sprite/Wrench.global_position
  29. node.direction = direction
  30. add_sibling(node)