brackeys-12/ui.gd
2024-09-15 03:29:19 -04:00

41 lines
1.3 KiB
GDScript

extends CanvasLayer
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var wood_count_label_2: Label = $UI/Background/Control3/WoodCountLabel2
var available_tween
func _ready() -> void:
Persister.persist_data("wood", 50)
Persister.persist_data("stone", 50)
Persister.persist_data("population", 3)
Persister.persist_data("avail_population", 3)
Persister.persist_data("max_population", 3)
Triggerer.listen("show_info", _on_show_info)
Triggerer.listen("hide_info", _on_hide_info)
func _process(delta: float) -> void:
if Input.is_action_just_pressed("lclick") and not Persister.get_value("game_started"):
Persister.persist_data("game_started", true)
animation_player.play("start")
wood_count_label_2.text = "%d available" % [Persister.get_value("avail_population")]
func _on_show_info(_data):
if available_tween:
available_tween.kill()
available_tween = create_tween()
available_tween.set_ease(Tween.EASE_OUT)
available_tween.set_trans(Tween.TRANS_BACK)
available_tween.tween_property(wood_count_label_2, "scale", Vector2.ONE, 0.5)
func _on_hide_info(_data):
if available_tween:
available_tween.kill()
available_tween = create_tween()
available_tween.set_ease(Tween.EASE_OUT)
available_tween.set_trans(Tween.TRANS_QUAD)
available_tween.tween_property(wood_count_label_2, "scale", Vector2.ZERO, 0.5)