blob: 4cc4ec5defca283faa1ade0e14639b8b523b686e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
)
|