41 lines
661 B
GDScript
41 lines
661 B
GDScript
extends Control
|
|
|
|
onready var label : Label = $MarginContainer/Label
|
|
|
|
var game_mode
|
|
var max_time = 3
|
|
|
|
func _ready():
|
|
Signals.connect("update_score",self,"update_score")
|
|
|
|
|
|
func update_score(score: int):
|
|
label.text = String(score)
|
|
|
|
func start(mode: String):
|
|
|
|
match mode:
|
|
"score":
|
|
update_score(0)
|
|
show()
|
|
"time":
|
|
update_score(max_time)
|
|
show()
|
|
var t = Timer.new()
|
|
t.set_wait_time(1)
|
|
add_child(t)
|
|
t.start()
|
|
for n in range(max_time,0,-1):
|
|
update_score(n)
|
|
yield(t,"timeout")
|
|
update_score(0)
|
|
Signals.emit_signal("win")
|
|
_:
|
|
print("game_mode not recognized by scoreUI")
|
|
|
|
|
|
|
|
func init(mode):
|
|
game_mode = mode
|
|
hide()
|
|
|