No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scoreUI.gd 847B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. extends Control
  2. onready var label : Label = $MarginContainer/Label
  3. onready var timer = $Timer
  4. var game_mode
  5. var max_time = 30
  6. var current_time = 0
  7. func _ready():
  8. Signals.connect("update_score",self,"update_score")
  9. func update_score(score: int):
  10. label.text = String(score)
  11. func start(mode: String):
  12. match mode:
  13. "score":
  14. update_score(0)
  15. show()
  16. "time":
  17. update_score(max_time)
  18. show()
  19. current_time = 0
  20. timer.start()
  21. _:
  22. print("game_mode not recognized by scoreUI")
  23. func set_max_time(time: int):
  24. max_time = time
  25. func init(mode, goal: int):
  26. game_mode = mode
  27. if (goal != 0):
  28. max_time = goal
  29. hide()
  30. func stop():
  31. timer.stop()
  32. func _on_Timer_timeout() -> void:
  33. current_time += 1
  34. var n = max_time - current_time
  35. if n < 0:
  36. n = 0
  37. update_score(n)
  38. if n == 0:
  39. Signals.emit_signal("win")
  40. timer.stop()