Files
imnotsick/main_hub.gd
T
2025-06-08 03:23:46 +02:00

80 lines
1.9 KiB
GDScript

extends Control
@export var TitleScreen: PackedScene
@export var Office: PackedScene
@export var Bedroom: PackedScene
@export var TextScreens: PackedScene
@export var DialogueScreens: PackedScene
var dialogue_intro = load("res://Dialogues/intro.dialogue")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#Adding Scenes
var title_screen = TitleScreen.instantiate()
var office = Office.instantiate()
var bedroom = Bedroom.instantiate()
var text_screens = TextScreens.instantiate()
var dialogue_screens = DialogueScreens.instantiate()
add_child(title_screen)
add_child(office)
add_child(bedroom)
add_child(text_screens)
add_child(dialogue_screens)
#Naming Scenes
title_screen.name = "TitleScreen"
office.name = "Office"
bedroom.name = "Bedroom"
text_screens.name = "TextScreens"
dialogue_screens.name = "DialogueScreens"
#Showing TitleScreen
title_screen.show()
#Connecting Signals
title_screen.connect("new_game_pressed", _on_new_game_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():
var text_container = $TextScreens/MarginContainer/IntroBoxContainer/TextContainer
transition("big", [$TitleScreen], [$TextScreens, text_container.get_child(0)])
await $TextScreens.next_slide
for i in 4:
transition("small", [text_container.get_child(i)], [text_container.get_child(i+1)])
await $TextScreens.next_slide
transition("big", [$TextScreens, text_container.get_child(4)], [$DialogueScreens])
await $TextScreens.next_slide
$DialogueScreens.dialogue(dialogue_intro, "start")
# Takes care of fading transitions between scenes
func transition(size, scenes_to_hide, scenes_to_show):
TransitionScreen.transition(size)
await TransitionScreen.fading_finished
for scene in scenes_to_hide:
scene.hide()
for scene in scenes_to_show:
scene.show()