Jam10/Scripts/CutsceneRunner.gd

134 lines
5.5 KiB
GDScript3
Raw Normal View History

2023-01-30 01:07:02 +00:00
extends Control
export var cutscene_name : String
export var next_scene_to_load : String
2023-01-30 02:39:59 +00:00
var text_speed : int = 30
2023-01-30 01:07:02 +00:00
var text_label : RichTextLabel
var animation_player : AnimationPlayer
var audio_stream_player : AudioStreamPlayer
var cutscene_index : int = 0
var cutscene_sub_index : int = 0
var this_text : String
var message_time_elapsed : float
var chars_rendered : int = 0
var dialogue_fading_in : bool = true
var cutscene_directory = {
"Cutscene1": [
2023-01-30 08:40:31 +00:00
["Kyouko is relaxing outside while neglecting her duties.",
"Aya flies across Myouren Temple while the Bunbunmaru Newspaper falls down from above and hits the ground, Kyouko notices it and picks it up."],
2023-01-30 01:07:02 +00:00
2023-01-30 08:40:31 +00:00
["Kyouko: Huh, whats this?"],
2023-01-30 02:39:59 +00:00
2023-01-30 08:40:31 +00:00
["She unfolds the paper and reads it."],
2023-01-30 02:39:59 +00:00
2023-01-30 08:40:31 +00:00
["Kyouko: A winter game competition, eh? I wonder what this is about?"],
["~~ Looking for something to do with your holiday? Then come on down to Moriya Shrine, were looking for competitors to participate for our winter festival, winners will receive a statue of the legendary Inari Okami which will grant blessing for the upcoming harvest.", "We hope to see you attend Moriyas Wanton Winter Wagor! ~~"],
["Kyouko was hesitant at first about attending the winter fest, but her boredom got the best of her and decided to journey to Moriya Shrine."],
["Kyouko: I made up my mind, I'm going to Moriya shrine to win that statue for myself!"],
["Kyouko decides to rush down to Moriya shrine to compete for the prize, despite not knowing what was in store for her.", "Kyouko arrives at Moriya Shrine, though shes a bit nervous to see a large crowd of people gather from all across Gensokyo."],
["Kyouko: This place looks crowded, Im not so sure about this…"],
["As her shyness grows, she turns her attention away from the crowd and to Sanae and Reimu, they both seem to be talking about something."],
["Reimu: So where'd ya get this statue anyway?", "Sanae: Oh, I just found it in our storage one day. Guess we had it all along, huh?", "Reimu: Huh, weird."],
["This piqued Kyoukos interest and she wondered just how valuable this statue would be if were to win it for herself, this gets her excited for the competition."],
["Kyouko: Well, I guess Ill have to do my best!"],
["As everyone in the crowd prepares for the winter games, Kyouko braces herself for whatever challenge faces her."],
2023-01-30 02:39:59 +00:00
],
"Cutscene2": [
2023-01-30 08:40:31 +00:00
["After a long competition, Kyouko was rewarded with the honor of opening the present that holds the statue inside, after she opened it everyone was greeted by a surprise."],
2023-01-30 02:39:59 +00:00
],
"Cutscene3": [
2023-01-30 08:40:31 +00:00
["Luna, Sunny, Star: Congratulations, youre the winner!", "Kyouko: Whaaaaaaaat?!?"],
["Kyouko was bewildered by what she had seen, it turns out this wasnt the Inari Okami but a prank!"],
["Sanae: Wait, this was all a setup?", "Sunny: Hehe, surprised?", "Star: We fooled you!", "Luna: You shouldve seen it coming!"],
["There was confusion among the crowd, Kyouko was troubled by all this."],
["Reimu: So you were the ones who set all this up!"],
["Sunny: Thats right. While everyone was busy competing for the Okami statue, we decided to hide ourselves in this present while pretending to be the statue itself!"],
["The fairies were greeted with dead silence for a brief moment until Kyouko started laughing. Reimu and Sanae looked at each other in confusion."],
["Kyouko: Bwhahaha, you got me good, I havent had this much fun in a while!"],
["The three fairies looked at each other in confusion at first, then decided to laugh all together while the crowd decided to leave.", "As the sun sets, Kyouko waves goodbye to the fairies as they part ways."],
["Kyouko: I cant wait to tell lady Byakuren about my journey once I return to Myouren Temple!"],
],
"LostRace": [
["You lost the race - try again!"],
],
"WonRace": [
["You won the race! Onto the next one!"],
2023-01-30 01:07:02 +00:00
],
}
func _ready():
text_label = find_node("RichTextLabel")
animation_player = find_node("AnimationPlayer")
audio_stream_player = find_node("AudioStreamPlayer")
animation_player.play("InitialFade")
2023-01-30 08:40:31 +00:00
if cutscene_name == "Cutscene2":
MusicController.play_score_end()
2023-01-30 01:07:02 +00:00
func advance_dialogue():
if cutscene_sub_index == cutscene_directory[cutscene_name][cutscene_index].size() - 1:
animation_player.play("DialogueFade")
else:
cutscene_sub_index += 1
message_time_elapsed = 0
chars_rendered = 0
func mid_dialogue_fade():
if cutscene_index == cutscene_directory[cutscene_name].size() - 1:
animation_player.stop()
animation_player.play("FinalFade")
else:
cutscene_index += 1
cutscene_sub_index = 0
message_time_elapsed = 0
chars_rendered = 0
dialogue_fading_in = true
func dialogue_fade_done():
dialogue_fading_in = false
func final_fade_done():
2023-01-30 08:02:47 +00:00
get_node("ColorRect").modulate.a = 255
2023-01-30 01:07:02 +00:00
get_tree().change_scene("res://Scenes/" + next_scene_to_load + ".tscn")
func _process(delta):
this_text = cutscene_directory[cutscene_name][cutscene_index][cutscene_sub_index]
2023-01-30 02:39:59 +00:00
if Input.is_action_just_released("mouse_click") and not dialogue_fading_in:
2023-01-30 01:07:02 +00:00
if chars_rendered < this_text.length():
message_time_elapsed = 60
else:
advance_dialogue()
if not dialogue_fading_in:
message_time_elapsed = min(60, message_time_elapsed + delta)
var chars_to_display : int = floor(message_time_elapsed * text_speed)
chars_to_display = min(this_text.length(), chars_to_display)
text_label.text = this_text.substr(0, chars_to_display)
if chars_to_display > chars_rendered:
audio_stream_player.play()
chars_rendered = chars_to_display