From 4e06d14ebd6a3e452fa190478c6b825bd81afd95 Mon Sep 17 00:00:00 2001 From: Henrique Alves Date: Sat, 16 Jul 2022 12:36:24 -0300 Subject: Add global and UIController --- Scenes/Global.gd | 12 ++++++++++++ Scenes/UIController.gd | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 Scenes/Global.gd create mode 100644 Scenes/UIController.gd diff --git a/Scenes/Global.gd b/Scenes/Global.gd new file mode 100644 index 0000000..4bef11b --- /dev/null +++ b/Scenes/Global.gd @@ -0,0 +1,12 @@ +extends Node + +onready var STARTING_TURNS = 20 +onready var BONUS_TURNS_STAGE_FINISH = 10 + +onready var turns = STARTING_TURNS setget set_turns + +signal update_ui + +func set_turns(t): + turns = t + emit_signal("update_ui") diff --git a/Scenes/UIController.gd b/Scenes/UIController.gd new file mode 100644 index 0000000..1599d03 --- /dev/null +++ b/Scenes/UIController.gd @@ -0,0 +1,8 @@ +extends CanvasLayer + +func _ready(): + Global.connect("update_ui", self, "_on_update_ui") + _on_update_ui() + +func _on_update_ui(): + $NumberOfTurns.text = "Number of turns: %d" % Global.turns -- cgit v1.2.3