diff options
Diffstat (limited to 'Scripts/Level Specific/1SpikyShrubs.gd')
-rw-r--r-- | Scripts/Level Specific/1SpikyShrubs.gd | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Scripts/Level Specific/1SpikyShrubs.gd b/Scripts/Level Specific/1SpikyShrubs.gd new file mode 100644 index 0000000..99747a2 --- /dev/null +++ b/Scripts/Level Specific/1SpikyShrubs.gd @@ -0,0 +1,27 @@ +extends Node2D + +@export var health = 1 + +var can_hurt = true + +var pler : Entity = null + +func _process(_delta: float) -> void: + if pler && can_hurt: + pler.damage(health) + can_hurt = false + $"Timer".start() + +func _on_area_2d_body_entered(body:Node2D) -> void: + if body is Entity: + if body.is_player && can_hurt: + pler = body + pler.get_node("PlayerMovement").speed /= 2 + +func _on_timer_timeout() -> void: + can_hurt = true + +func _on_area_2d_body_exited(_body:Node2D) -> void: + if pler: + pler.get_node("PlayerMovement").speed *= 2 + pler = null |