ld56/Scenes/Worm/enemy.gd

37 lines
790 B
GDScript3
Raw Permalink Normal View History

2024-10-05 10:39:19 +00:00
extends Node2D
signal enemy_attacked
2024-10-06 17:38:16 +00:00
@export var color:Color
2024-10-05 10:39:19 +00:00
func button_pressed():
2024-10-06 17:38:16 +00:00
$AnimatedSprite2D.play("defeated_3")
2024-10-05 10:39:19 +00:00
2024-10-06 17:38:16 +00:00
func _process(delta: float) -> void:
$AnimatedSprite2D.modulate=color
2024-10-06 22:33:18 +00:00
#$AnimatedHack.modulate = color
func _ready() -> void:
2024-10-06 17:38:16 +00:00
$AnimatedSprite2D.play("attack")
2024-10-06 19:08:32 +00:00
func mirror():
scale.x = -scale.x
func _on_animated_sprite_2d_animation_finished() -> void:
2024-10-06 17:38:16 +00:00
if($AnimatedSprite2D.animation == "attack"):
enemy_attacked.emit()
2024-10-06 19:08:32 +00:00
$AnimatedSprite2D.play("attack_2")
return
2024-10-06 22:33:18 +00:00
2024-10-06 19:08:32 +00:00
match $AnimatedSprite2D.animation:
2024-10-06 22:33:18 +00:00
"attack_2":
$AnimatedHack.play("default")
$AnimatedHack.visible = true
$AnimatedSprite2D.visible = false
"defeated_3", "defeated_2", "defeated_4":
2024-10-06 19:08:32 +00:00
queue_free()
return
2024-10-06 22:33:18 +00:00
func _on_animated_hack_animation_finished() -> void:
queue_free()