2025-05-18 14:16:22 +00:00
|
|
|
extends ProgressBar
|
|
|
|
|
2025-05-18 14:51:07 +00:00
|
|
|
var addAmount: float
|
2025-05-18 14:16:22 +00:00
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
await get_tree().process_frame
|
|
|
|
var crystals = get_tree().get_nodes_in_group("crystals")
|
2025-05-18 15:06:51 +00:00
|
|
|
addAmount = 100.0 / crystals.size()
|
2025-05-18 14:51:07 +00:00
|
|
|
print("Pulled " + str(crystals.size()) + " crystals from scene")
|
|
|
|
|
2025-05-18 14:16:22 +00:00
|
|
|
for crystal in crystals:
|
|
|
|
print("Connecting crystal: " + crystal.name)
|
|
|
|
crystal.connect("crystal_picked_up", Callable(self, "collect"))
|
|
|
|
|
|
|
|
func collect():
|
2025-05-18 14:51:07 +00:00
|
|
|
print("Collected crystal")
|
2025-05-18 15:06:51 +00:00
|
|
|
value += addAmount
|
|
|
|
|
|
|
|
if value > 99.0:
|
|
|
|
value = 100.0
|
2025-05-18 15:17:13 +00:00
|
|
|
|
2025-05-19 12:41:35 +00:00
|
|
|
signal complete
|
2025-05-18 15:17:13 +00:00
|
|
|
|
|
|
|
func _on_value_changed(value: float) -> void:
|
|
|
|
if value == 100.0:
|
2025-05-19 12:41:35 +00:00
|
|
|
emit_signal("complete")
|