From 46556d864b9685c3b09a0038f5de83966fe7ff94 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 10 Aug 2023 11:48:05 +0200 Subject: Initial commit --- Scenes/UI/Health.gd | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Scenes/UI/Health.gd (limited to 'Scenes/UI/Health.gd') 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) -- cgit v1.2.3