summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-05-23 14:11:43 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-05-23 14:11:43 +0200
commit06647b11ee163bc40daf454d87e1fcae563c3ced (patch)
tree866823ed79fa1c3bbdcb8b0be417f028f0c92d9b /Scenes/Entities/Enemies
parent276b7664bd4a475a3ca93a682c16b49c504c58f7 (diff)
update
Diffstat (limited to 'Scenes/Entities/Enemies')
-rw-r--r--Scenes/Entities/Enemies/Components/Health.gd5
-rw-r--r--Scenes/Entities/Enemies/Projectile.gd2
-rw-r--r--Scenes/Entities/Enemies/Tree.gd5
-rw-r--r--Scenes/Entities/Enemies/Tree.tscn2
4 files changed, 11 insertions, 3 deletions
diff --git a/Scenes/Entities/Enemies/Components/Health.gd b/Scenes/Entities/Enemies/Components/Health.gd
index 6f65e79..2bd2447 100644
--- a/Scenes/Entities/Enemies/Components/Health.gd
+++ b/Scenes/Entities/Enemies/Components/Health.gd
@@ -21,6 +21,8 @@ var drop_items = [
preload("res://Scenes/Entities/Objects/Coin.tscn"),
]
+var is_dying = false
+
func _ready():
if component_movement_path:
@@ -30,11 +32,12 @@ func _ready():
func take_damage():
health -= 1
- if health <= 0:
+ if health <= 0 and not is_dying:
death()
func death():
+ is_dying = true
emit_signal("died")
if component_movement: # stop all movement
diff --git a/Scenes/Entities/Enemies/Projectile.gd b/Scenes/Entities/Enemies/Projectile.gd
index af283b4..02a1470 100644
--- a/Scenes/Entities/Enemies/Projectile.gd
+++ b/Scenes/Entities/Enemies/Projectile.gd
@@ -13,7 +13,7 @@ func _ready():
velocity = position.direction_to(target) * speed
-func _physics_process(delta):
+func _physics_process(_delta):
$AnimatedSprite2D.play("default")
move_and_slide()
diff --git a/Scenes/Entities/Enemies/Tree.gd b/Scenes/Entities/Enemies/Tree.gd
index 5572e02..bbd02a9 100644
--- a/Scenes/Entities/Enemies/Tree.gd
+++ b/Scenes/Entities/Enemies/Tree.gd
@@ -3,6 +3,7 @@ extends CharacterBody2D
@onready var component_collision: ComponentCollision = $Collision
@onready var component_movement: ComponentMovement = $Movement
+@onready var component_health: ComponentHealth = $Health
func _ready():
@@ -16,6 +17,10 @@ func _ready():
$AnimatedSprite2D.play("spawn")
$AnimatedSprite2D.stop()
$AnimatedSprite2D.set_frame_and_progress(0, 0)
+
+ $Health.connect("died", func():
+ $Detection.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false)
+ )
func _physics_process(delta):
diff --git a/Scenes/Entities/Enemies/Tree.tscn b/Scenes/Entities/Enemies/Tree.tscn
index 3a0de4a..f216159 100644
--- a/Scenes/Entities/Enemies/Tree.tscn
+++ b/Scenes/Entities/Enemies/Tree.tscn
@@ -141,7 +141,7 @@ script = ExtResource("1_ktvfx")
texture_filter = 1
position = Vector2(0, -8)
sprite_frames = SubResource("SpriteFrames_c5ryj")
-animation = &"spawn"
+animation = &"death_post"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -8)