A game created for the Godot Wild Jam #21
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.

55 lines
2.1KB

  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(true)
  13. _agg_bar.max_value = 100.0
  14. _agg_bar.value = 0.0
  15. _need_bar.max_value = 100.0
  16. _need_bar.value = 0.0
  17. _content_bar.max_value = 100.0
  18. _content_bar.value = 0.0
  19. _nrg_bar.max_value = get_node("../Player").max_energy
  20. _nrg_bar.value = get_node("../Player").get_current_energy()
  21. func _process(delta):
  22. UpdateMoodBars()
  23. UpdateTimer()
  24. func _toClockString(v):
  25. if v < 10:
  26. return "0" + String(v)
  27. return String(v)
  28. func UpdateTimer():
  29. var p = get_parent()
  30. var h = p.get_hours()
  31. var m = p.get_minutes()
  32. var s = p.get_seconds()
  33. get_node("Timer/TimeText").text = _toClockString(h) + ":" + _toClockString(m) + ":" + _toClockString(s)
  34. func UpdateMoodBars():
  35. var p = get_node("../Player")
  36. var mc = p.get_mood().get_mood_color()
  37. _agg_bar_tween.interpolate_property(_agg_bar, "value", _agg_bar.value, mc.r * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  38. _agg_bar_tween.start()
  39. _need_bar_tween.interpolate_property(_need_bar, "value", _need_bar.value, mc.g * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  40. _need_bar_tween.start()
  41. _content_bar_tween.interpolate_property(_content_bar, "value", _content_bar.value, mc.b * 100, 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  42. _content_bar_tween.start()
  43. _nrg_bar_tween.interpolate_property(_nrg_bar, "value", _nrg_bar.value, p.get_current_energy(), 0.1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
  44. _nrg_bar_tween.start()