A game created for the Godot Wild Jam #21
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

68 linhas
2.3KB

  1. extends CanvasLayer
  2. onready var _agg_bar = get_node("PlayerUI/MoodBars/Aggression/Bar/Progress")
  3. onready var _agg_bar_tween = get_node("PlayerUI/MoodBars/Aggression/Bar/Progress/Tween")
  4. onready var _need_bar = get_node("PlayerUI/MoodBars/Neediness/Bar/Progress")
  5. onready var _need_bar_tween = get_node("PlayerUI/MoodBars/Neediness/Bar/Progress/Tween")
  6. onready var _content_bar = get_node("PlayerUI/MoodBars/Contentment/Bar/Progress")
  7. onready var _content_bar_tween = get_node("PlayerUI/MoodBars/Contentment/Bar/Progress/Tween")
  8. onready var _nrg_bar = get_node("PlayerUI/NRG/Bar/Progress")
  9. onready var _nrg_bar_tween = get_node("PlayerUI/NRG/Bar/Progress/Tween")
  10. # Called when the node enters the scene tree for the first time.
  11. func _ready():
  12. #set_process_input(true)
  13. set_process(true)
  14. _agg_bar.max_value = 100.0
  15. _agg_bar.value = 0.0
  16. _need_bar.max_value = 100.0
  17. _need_bar.value = 0.0
  18. _content_bar.max_value = 100.0
  19. _content_bar.value = 0.0
  20. _nrg_bar.max_value = get_node("../Player").max_energy
  21. _nrg_bar.value = get_node("../Player").get_current_energy()
  22. func _input(event):
  23. if not $Timer.visible:
  24. return
  25. if event.is_action_pressed("ui_cancel"):
  26. get_parent().pause(true)
  27. $Menus/PauseMenu.show()
  28. func _process(delta):
  29. UpdateMoodBars()
  30. UpdateTimer()
  31. func _toClockString(v):
  32. if v < 10:
  33. return "0" + String(v)
  34. return String(v)
  35. func UpdateTimer():
  36. var p = get_parent()
  37. var h = p.get_hours()
  38. var m = p.get_minutes()
  39. var s = p.get_seconds()
  40. get_node("Timer/TimeText").text = _toClockString(h) + ":" + _toClockString(m) + ":" + _toClockString(s)
  41. func UpdateMoodBars():
  42. var p = get_node("../Player")
  43. var mc = p.get_mood().get_mood_color()
  44. _agg_bar_tween.interpolate_property(_agg_bar, "value", _agg_bar.value, mc.r * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  45. _agg_bar_tween.start()
  46. _need_bar_tween.interpolate_property(_need_bar, "value", _need_bar.value, mc.g * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  47. _need_bar_tween.start()
  48. _content_bar_tween.interpolate_property(_content_bar, "value", _content_bar.value, mc.b * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  49. _content_bar_tween.start()
  50. _nrg_bar_tween.interpolate_property(_nrg_bar, "value", _nrg_bar.value, p.get_current_energy(), 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  51. _nrg_bar_tween.start()
  52. func _on_PM_Resume_pressed():
  53. get_parent().pause(false)
  54. $Menus/PauseMenu.hide()