76 lines
2.1 KiB
GDScript
76 lines
2.1 KiB
GDScript
extends Control
|
|
@export var TitleScreen: PackedScene
|
|
@export var Office: PackedScene
|
|
@export var Bedroom: PackedScene
|
|
@export var TextScreens: PackedScene
|
|
|
|
|
|
# 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()
|
|
|
|
add_child(title_screen)
|
|
add_child(office)
|
|
add_child(bedroom)
|
|
add_child(text_screens)
|
|
|
|
#Naming Scenes
|
|
title_screen.name = "TitleScreen"
|
|
office.name = "Office"
|
|
bedroom.name = "Bedroom"
|
|
text_screens.name = "TextScreens"
|
|
|
|
#Hiding Scenes
|
|
title_screen.hide()
|
|
office.hide()
|
|
bedroom.hide()
|
|
|
|
#Hiding Text_Screens
|
|
text_screens.hide()
|
|
for scene in $TextScreens/MarginContainer.get_children():
|
|
scene.hide()
|
|
$TextScreens/SkipContainer.hide()
|
|
title_screen.show()
|
|
|
|
#Connecting Signals
|
|
title_screen.connect("new_game_pressed", _on_new_game_pressed)
|
|
|
|
|
|
|
|
#get_tree().change_scene_to_file("res://corridor.tscn")
|
|
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():
|
|
transition([$TitleScreen], [$TextScreens, $TextScreens/MarginContainer/TextIntro1, $TextScreens/SkipContainer])
|
|
await $TextScreens.slide_finished
|
|
transition([$TextScreens/MarginContainer/TextIntro1], [$TextScreens/MarginContainer/TextIntro2])
|
|
await $TextScreens.slide_finished
|
|
transition([$TextScreens/MarginContainer/TextIntro2], [$TextScreens/MarginContainer/TextIntro3])
|
|
await $TextScreens.slide_finished
|
|
transition([$TextScreens/MarginContainer/TextIntro3], [$TextScreens/MarginContainer/TextIntro4])
|
|
await $TextScreens.slide_finished
|
|
transition([$TextScreens/MarginContainer/TextIntro4], [$TextScreens/MarginContainer/TextIntro5])
|
|
|
|
|
|
# Takes care of fading transitions between scenes
|
|
func transition(scenes_to_hide, scenes_to_show):
|
|
TransitionScreen.transition()
|
|
await TransitionScreen.on_transition_finished
|
|
|
|
for scene in scenes_to_hide:
|
|
scene.hide()
|
|
for scene in scenes_to_show:
|
|
scene.show()
|