From 1aac583cee47d232ef22d8c5df97b888f689ab96 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 9 Oct 2024 17:20:55 +0200 Subject: intermediate commit --- Effects/BurnEffect.tscn | 6 ++++++ Effects/SlowEffect.gd | 14 +++++--------- Effects/burn_effect.gd | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 Effects/BurnEffect.tscn create mode 100644 Effects/burn_effect.gd (limited to 'Effects') diff --git a/Effects/BurnEffect.tscn b/Effects/BurnEffect.tscn new file mode 100644 index 0000000..a8e1ed0 --- /dev/null +++ b/Effects/BurnEffect.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dmj3et5exg4s5"] + +[ext_resource type="Script" path="res://Effects/burn_effect.gd" id="1_8my4q"] + +[node name="BurnEffect" type="Node2D"] +script = ExtResource("1_8my4q") diff --git a/Effects/SlowEffect.gd b/Effects/SlowEffect.gd index 27dcc59..a3070ca 100644 --- a/Effects/SlowEffect.gd +++ b/Effects/SlowEffect.gd @@ -12,15 +12,11 @@ var magnitude: float = 0.5 : func _ready(): - if self.name != "SlowEffect" and unit.has_node("SlowEffect"): - unit.get_node("SlowEffect").set_duration(5.0) - queue_free() - else: - add() - set_duration(5.0) - duration_finished.connect(func(): - remove() - ) + add() + set_duration(5.0) + duration_finished.connect(func(): + remove() + ) func add(): diff --git a/Effects/burn_effect.gd b/Effects/burn_effect.gd new file mode 100644 index 0000000..9693292 --- /dev/null +++ b/Effects/burn_effect.gd @@ -0,0 +1,20 @@ +extends Effect + + +@onready var unit: Unit = get_parent() + +var base_modulate: Color + + +func _ready(): + base_modulate = unit.get_node("Sprite2D").self_modulate + + set_duration(5.0) + + set_tick(1.0) + tick_finished.connect(func(): + unit.set_hp(unit.hp - 5) + unit.get_node("Sprite2D").self_modulate = Color(1, 0, 0) + await get_tree().create_timer(0.1).timeout + unit.get_node("Sprite2D").self_modulate = base_modulate + ) -- cgit v1.2.3