diff options
Diffstat (limited to 'boss_hp_bar.gd')
-rw-r--r-- | boss_hp_bar.gd | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/boss_hp_bar.gd b/boss_hp_bar.gd new file mode 100644 index 0000000..4cc4ec5 --- /dev/null +++ b/boss_hp_bar.gd @@ -0,0 +1,26 @@ +extends Control + + +var max_hp: int + +@onready var hp_scene = preload("res://BossHP.tscn") + + +func initialize(hp: int): + max_hp = hp + + for child in $HBoxContainer.get_children(): + $HBoxContainer.remove_child(child) + + for n in range(hp): + SoundManager.play_sound("BossHpFill") + $HBoxContainer.add_child(hp_scene.instantiate()) + await get_tree().create_timer(0.1).timeout + + Game.boss_hp_changed.connect(func(new_hp): + for n in range(max_hp): + if n < new_hp: + $HBoxContainer.get_child(n).set_full() + else: + $HBoxContainer.get_child(n).set_empty() + ) |