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.

EndRecap.gd 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. extends "res://util/StatsHandler.gd"
  2. onready var progress_container = $VBoxContainer/Control/RecapContainer/MarginContainer/Panel/MarginContainer/VBoxContainer/MarginContainer/GaugesContainer
  3. onready var choices_container = $VBoxContainer/MarginContainer/MarginContainer/HBoxContainer2
  4. onready var main_container = $VBoxContainer/Control
  5. onready var main_tween = $VBoxContainer/Control/Tween
  6. onready var recap_container = $VBoxContainer/Control/RecapContainer
  7. onready var characters_container = $VBoxContainer/Control/CharactersContainer
  8. onready var gauges_timer = $GaugesTimer
  9. onready var choices_timer = $ChoicesTimer
  10. var shown_gauge_index = 0
  11. var shown_choice_index = 0
  12. func _ready():
  13. progress_container.connect("mouse_entered", self, '_on_mouse_entered')
  14. progress_container.connect("mouse_exited", self, '_on_mouse_exited')
  15. _set_characters_relations()
  16. print(gauges_values)
  17. print(relations_values)
  18. print(choices_values)
  19. gauges_timer.start()
  20. # Do not wait to show the first choice
  21. _on_ChoicesTimer_timeout()
  22. choices_timer.start()
  23. _play_start_animation()
  24. func _play_start_animation():
  25. main_tween.interpolate_property(recap_container, "rect_position", Vector2(0, recap_container.rect_size.y/3), Vector2(0, 0), 0.8, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
  26. main_tween.interpolate_property(recap_container, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), 0.8, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
  27. _setup_character_animation(characters_container.get_child(0), true)
  28. _setup_character_animation(characters_container.get_child(2), false)
  29. main_tween.start()
  30. func _setup_character_animation(character: Control, is_left: bool):
  31. var delay = 0.3 if is_left else 0.5
  32. var x_pos = character.rect_position.x - character.rect_size.x/3 if is_left else character.rect_position.x + character.rect_size.x/3
  33. character.modulate = Color(1, 1, 1, 0)
  34. main_tween.interpolate_property(character, "modulate", Color(1, 1, 1, 0), Color(1, 1, 1, 1), 0.8, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT, delay)
  35. main_tween.interpolate_property(character, "rect_position", Vector2(x_pos, character.rect_position.y), character.rect_position, 0.8, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT, delay)
  36. func _on_mouse_exited():
  37. main_container.move_child(recap_container, 0)
  38. func _on_mouse_entered():
  39. # Make sure the recap is behind the characters
  40. # This allows showing the infobox above the recap
  41. main_container.move_child(recap_container, 1)
  42. func _set_characters_relations():
  43. for i in range(0, relations_values.size()):
  44. var child_index = i
  45. # take the spacer into account
  46. if i >= 1:
  47. child_index += 1
  48. characters_container.get_child(child_index).relation = relations_values[i]
  49. func _on_GaugesTimer_timeout() -> void:
  50. var c = progress_container.get_child(shown_gauge_index)
  51. c.progress = gauges_values[shown_gauge_index]
  52. shown_gauge_index += 1
  53. if shown_gauge_index >= progress_container.get_child_count():
  54. gauges_timer.stop()
  55. func _on_ChoicesTimer_timeout() -> void:
  56. # take spacers into account
  57. var c = choices_container.get_child(shown_choice_index * 2)
  58. if shown_choice_index < choices_values.size():
  59. c.choice = int(choices_values[shown_choice_index / 2])
  60. shown_choice_index += 1
  61. if shown_choice_index >= choices_container.get_child_count():
  62. choices_timer.stop()
  63. else:
  64. choices_timer.stop()
  65. func _on_ExitButton_pressed():
  66. Transit.change_scene("res://scenes/MainMenu.tscn", 0.5)