diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-10 11:48:05 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-10 11:48:05 +0200 |
commit | 46556d864b9685c3b09a0038f5de83966fe7ff94 (patch) | |
tree | c68082eacd35559e14565d1598dd694972fb8e0e /Scenes/UI/Health.gd |
Initial commit
Diffstat (limited to 'Scenes/UI/Health.gd')
-rw-r--r-- | Scenes/UI/Health.gd | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Scenes/UI/Health.gd b/Scenes/UI/Health.gd new file mode 100644 index 0000000..eb88522 --- /dev/null +++ b/Scenes/UI/Health.gd @@ -0,0 +1,41 @@ +extends Control + + +@export var color_full: Color = Color(1, 0, 0, 1) +@export var color_empty: Color = Color(0, 0, 0, 1) +@export var color_extra_full: Color = Color(1, 1, 0, 1) +@export var color_extra_empty: Color = Color(0, 0, 0, 0) + + +func set_full(): + self.set_color_all(self.color_full) + + +func set_empty(): + self.set_color_all(self.color_empty) + + +func set_full_parts(parts: int): + self.set_empty() + for i in range(1, parts+1): + self.set_color(i, self.color_full) + + +func set_extra_full(): + self.set_color_all(self.color_extra_full) + + +func set_extra_full_parts(parts: int): + self.set_color_all(self.color_extra_empty) + for i in range(1, parts+1): + self.set_color(i, self.color_extra_full) + + +func set_color(index: int, color: Color): + var color_rect: ColorRect = get_node("ColorRect" + str(index)) + color_rect.set_color(color) + + +func set_color_all(color: Color): + for i in range(1, 4+1): + self.set_color(i, color) |