extends Control @export var TitleScreen: PackedScene @export var ScreeningDesk: PackedScene @export var Bedroom: PackedScene @export var TextScreens: PackedScene @export var DialogueScreens: PackedScene # Called when the node enters the scene tree for the first time. func _ready() -> void: #Adding Scenes var title_screen = TitleScreen.instantiate() var screening_desk = ScreeningDesk.instantiate() var bedroom = Bedroom.instantiate() var text_screens = TextScreens.instantiate() var dialogue_screens = DialogueScreens.instantiate() add_child(title_screen) add_child(screening_desk) add_child(bedroom) add_child(text_screens) add_child(dialogue_screens) #Naming Scenes title_screen.name = "TitleScreen" screening_desk.name = "ScreeningDesk" bedroom.name = "Bedroom" text_screens.name = "TextScreens" dialogue_screens.name = "DialogueScreens" #Showing TitleScreen title_screen.show() #Connecting Signals title_screen.connect("new_game_pressed", self._on_new_game_pressed) title_screen.connect("load_pressed", self._on_load_pressed) title_screen.connect("settings_pressed", self._on_settings_pressed) screening_desk.connect("recovery_pressed", self._on_recovery_pressed) pass # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass # Starts a new game func _on_new_game_pressed(): #Offering to skip Introduction UI.confirmation_text.text = "[center]Do you wish to skip the introduction ?[/center]" UI.confirmation_yes.pressed.connect(skip_intro, CONNECT_ONE_SHOT) UI.confirmation_no.pressed.connect(play_intro, CONNECT_ONE_SHOT) UI.confirmation_dialog.show() TransitionScreen.mask.visible = true #Skips the introduction func skip_intro(): #Disconnecting the other Signal from the Confirmation Dialogue UI.confirmation_no.disconnect("pressed", play_intro) #Starting Day Loop start_day_loop() #Plays the entire introduction func play_intro(): #Disconnecting the other Signal from the Confirmation Dialogue UI.confirmation_yes.disconnect("pressed", skip_intro) #Playing the Intro #Text Slides var text_container = $TextScreens/MarginContainer/IntroBoxContainer/TextContainer TransitionScreen.transition("big", [$TitleScreen], [$TextScreens, $TextScreens/MarginContainer/IntroBoxContainer/Header, text_container.get_child(0), UI, UI.get_node("UI/SkipContainer")]) await UI.next_slide for i in 4: TransitionScreen.transition("small", [text_container.get_child(i)], [text_container.get_child(i+1)]) await UI.next_slide #Meeting Room Dialogue TransitionScreen.transition("big", [$TextScreens, $TextScreens/MarginContainer, text_container.get_child(4), UI, UI.get_node("UI/SkipContainer")], [$DialogueScreens]) await TransitionScreen.transition_finished DialogueManager.show_dialogue_balloon(Globals.dialogue_intro, "start") await DialogueManager.dialogue_ended #Starting Day Loop start_day_loop() #Starts the Day Loop func start_day_loop(): #Transitioning to Day Screen $TextScreens/Day.text = "[center]DAY " + str(Globals.day_count) + "[/center]" TransitionScreen.transition("big", [$DialogueScreens, $TitleScreen], [$TextScreens, $TextScreens/Day]) await TransitionScreen.transition_finished await get_tree().create_timer(3.0).timeout #Transitioning to the Screening Desk TransitionScreen.transition("big", [$TextScreens, $TextScreens/Day], [$ScreeningDesk, $ScreeningDesk.alone_controls, UI, UI.get_node("UI/UpperContainer")]) await TransitionScreen.transition_finished #Finally starting the Game Loop $ScreeningDesk.new_patient(Globals.patient_id) func _on_recovery_pressed(): var scenes_to_hide = [$ScreeningDesk.end_of_day_controls, $ScreeningDesk] var scenes_to_show:Array[Node] = [$Bedroom] TransitionScreen.transition("big", scenes_to_hide, scenes_to_show) await TransitionScreen.transition_finished DialogueManager.show_dialogue_balloon(Globals.dialogue_recovery, "end_of_day_" + str(Globals.day_count)) await DialogueManager.dialogue_ended Globals.day_count += 1 #Transitioning to Day Screen $TextScreens/Day.text = "[center]DAY " + str(Globals.day_count) + "[/center]" scenes_to_hide = [$Bedroom] scenes_to_show = [$TextScreens, $TextScreens/Day] TransitionScreen.transition("big", scenes_to_hide, scenes_to_show) await TransitionScreen.transition_finished await get_tree().create_timer(3.0).timeout #Transitioning to Screening Desk scenes_to_hide = scenes_to_show scenes_to_show = [$ScreeningDesk, $ScreeningDesk.alone_controls] TransitionScreen.transition("big", scenes_to_hide, scenes_to_show) await TransitionScreen.transition_finished $ScreeningDesk.new_patient(Globals.patient_id) func save_game(save_slot:String): var save_data = { "day_count": Globals.day_count, "patient_count": Globals.patient_count, "patient_id": Globals.patient_id } var file = FileAccess.open("res://Saves/save_" + save_slot + ".json", FileAccess.WRITE) if file: var json_string = JSON.stringify(save_data) print(json_string) file.store_string(json_string) file.close() print("Game saved successfully!") else: print("Failed to open file for saving.") func load_game(save_slot:String): var file = FileAccess.open("res://Saves/save_" + save_slot + ".json", FileAccess.READ) if file: var json_string = file.get_as_text() file.close() var load_data = JSON.parse_string(json_string) if load_data == OK: print(load_data) Globals.day_count = load_data["day_count"] Globals.patient_count = load_data["patient_count"] Globals.patient_id = load_data["patient_id"] else: print("Failed to parse Loading Data.") func _on_save_pressed():