42 lines
No EOL
919 B
GDScript
42 lines
No EOL
919 B
GDScript
extends Control
|
|
class_name UIComponent
|
|
|
|
var update_interval : float = 1
|
|
var last_update : float = 0
|
|
|
|
@onready var nectar_bar = get_node("%NectarBar")
|
|
@onready var help_text_container = get_node("%HelpTextContainer")
|
|
@onready var help_text_items = help_text_container.get_children()
|
|
@onready var level_text_label = get_node("%LevelText")
|
|
|
|
func _ready():
|
|
|
|
hide_help_text()
|
|
update_ui()
|
|
|
|
func _process(delta):
|
|
last_update += delta
|
|
|
|
if last_update > update_interval:
|
|
last_update = 0
|
|
update_ui()
|
|
|
|
if GameState.level_complete:
|
|
update_ui()
|
|
|
|
func update_ui():
|
|
nectar_bar.value = GameState.gathered_nectar
|
|
nectar_bar.max_value = GameState.required_nectar
|
|
|
|
func hide_help_text():
|
|
for item in help_text_items:
|
|
item.hide()
|
|
|
|
func show_help_text(label: String):
|
|
hide_help_text()
|
|
for item in help_text_items:
|
|
if item.name == label:
|
|
item.show()
|
|
|
|
func update_level_text(text: String):
|
|
level_text_label.text = text |