-
Notifications
You must be signed in to change notification settings - Fork 1
/
TitleScreen.gd
319 lines (267 loc) · 10.5 KB
/
TitleScreen.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
extends Node2D
class_name TitleScreen
onready var gamelogic = get_tree().get_root().find_node("LevelScene", true, false).gamelogic;
onready var holder : Label = get_node("Holder");
onready var pointer : Sprite = get_node("Holder/Pointer");
onready var beginbutton : Button = get_node("Holder/BeginButton");
onready var controlsbutton : Button = get_node("Holder/ControlsButton");
onready var settingsbutton : Button = get_node("Holder/SettingsButton");
onready var creditsbutton : Button = get_node("Holder/CreditsButton");
onready var disclaimer : Label = get_node("Holder/Disclaimer");
var only_mouse = true;
var using_controller = false;
var end_timer = 0.0;
var end_timer_max = 0.0;
var cutscene_step = 0;
var cutscene_step_cooldown = 0.0;
var has_shown_advance_label = false;
var skip_cutscene_label = null;
var ghost_type = 0;
var ghost_timer = 0.0;
var ghost_timer_max = 0.2;
var is_web = false;
func _ready() -> void:
var os_name = OS.get_name();
if (os_name == "HTML5" or os_name == "Android" or os_name == "iOS"):
is_web = true;
if (!is_web):
disclaimer.visible = false;
$CutsceneHolder.visible = false;
$CutsceneHolder/HeavyPortal.visible = false;
$CutsceneHolder/HeavyActor.visible = false;
$CutsceneHolder/HeavyFix.visible = false;
$CutsceneHolder/LightPortal.visible = false;
$CutsceneHolder/LightActor.visible = false;
$CutsceneHolder/LightFix.visible = false;
beginbutton.connect("pressed", self, "_beginbutton_pressed");
controlsbutton.connect("pressed", self, "_controlsbutton_pressed");
settingsbutton.connect("pressed", self, "_settingsbutton_pressed");
creditsbutton.connect("pressed", self, "_creditsbutton_pressed");
gamelogic.target_track = 10;
gamelogic.fadeout_timer_max = 1.0;
gamelogic.fadeout_timer = gamelogic.fadeout_timer_max - 0.0001;
holder.modulate = Color(1, 1, 1, 0);
var tween = get_tree().create_tween()
tween.tween_property(holder, "modulate", Color.white, 1)
func _beginbutton_pressed() -> void:
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
return;
cutscene_step();
func _controlsbutton_pressed() -> void:
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
return;
var a = preload("res://Controls.tscn").instance();
gamelogic.add_to_ui_stack(a, get_parent());
func _settingsbutton_pressed() -> void:
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
return;
var a = preload("res://Settings.tscn").instance();
gamelogic.add_to_ui_stack(a, get_parent());
func _creditsbutton_pressed() -> void:
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
return;
var a = preload("res://CreditsModal.tscn").instance();
gamelogic.add_to_ui_stack(a, get_parent());
func cutscene_step() -> void:
if (cutscene_step_cooldown < 0.1):
return;
if ($CutsceneHolder/AnimationPlayer.current_animation == "Animate" and $CutsceneHolder/AnimationPlayer.is_playing()):
return;
cutscene_step_cooldown = 0;
$CutsceneHolder/AdvanceLabel.visible = false;
match cutscene_step:
0:
beginbutton.queue_free();
controlsbutton.queue_free();
settingsbutton.queue_free();
creditsbutton.queue_free();
pointer.queue_free();
$Holder/Label.visible = false;
disclaimer.visible = false;
$ColorRect2.queue_free();
pointer = null;
$CutsceneHolder.visible = true;
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel1, "modulate", Color.white, 0.5);
gamelogic.target_track = 11;
gamelogic.fadeout_timer_max = 1.0;
gamelogic.fadeout_timer = gamelogic.fadeout_timer_max - 0.0001;
gamelogic.play_sound("noodling");
1:
$MainMenuBg.visible = false;
$PatagameNoBg.visible = false;
$Eyes.visible = false;
$Holder/Logosmol.visible = false;
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel2, "modulate", Color.white, 0.5);
gamelogic.play_sound("alert");
2:
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel3, "modulate", Color.white, 0.5);
gamelogic.play_sound("alert2");
gamelogic.target_track = 12;
gamelogic.fadeout_timer_max = 1.5;
gamelogic.fadeout_timer = 0.0;
3:
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel4, "modulate", Color.white, 0.5);
gamelogic.play_sound("alert3");
4:
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel5, "modulate", Color.white, 0.5);
gamelogic.play_sound("intothewarp");
5:
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/ColorRect2, "modulate", Color.white, 2.0);
gamelogic.target_track = -1;
gamelogic.fadeout_timer_max = 2.0;
gamelogic.fadeout_timer = 0.0;
gamelogic.play_sound("getgreenality");
6:
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/Panel6, "modulate", Color.white, 1.0);
$CutsceneHolder/Panel1.visible = false;
$CutsceneHolder/Panel2.visible = false;
$CutsceneHolder/Panel3.visible = false;
$CutsceneHolder/Panel4.visible = false;
$CutsceneHolder/Panel5.visible = false;
gamelogic.target_track = 13;
gamelogic.fadeout_timer_max = 1.0;
gamelogic.fadeout_timer = gamelogic.fadeout_timer_max - 0.0001;
$CutsceneHolder/AnimationPlayer.play("Animate");
has_shown_advance_label = false;
ghost_type = 1;
7:
begin_the_end();
cutscene_step += 1;
func begin_the_end() -> void:
if (end_timer_max > 0.0):
return;
ghost_type = 0;
end_timer_max = 4.0;
gamelogic.load_level_direct(0);
gamelogic.fadeout_timer_max = 6.8;
gamelogic.fadeout_timer = 0.0;
gamelogic.play_won("thejourneybegins");
if (gamelogic.puzzles_completed == 0 and only_mouse):
gamelogic.save_file["virtual_buttons"] = 1;
gamelogic.setup_virtual_buttons();
func advance_label() -> void:
if (has_shown_advance_label or (cutscene_step > 1 and cutscene_step < 7)):
return;
has_shown_advance_label = true;
$CutsceneHolder/AdvanceLabel.visible = true;
var tween = get_tree().create_tween()
tween.tween_property($CutsceneHolder/AdvanceLabel, "modulate", Color.white, 1);
if (only_mouse):
$CutsceneHolder/AdvanceLabel.text = "(Left click or tap the screen to advance cutscene)";
else:
$CutsceneHolder/AdvanceLabel.text = "(" + gamelogic.human_readable_input("ui_accept", 1) + " to advance cutscene)";
func skip_cutscene_label_grows(delta: float) -> void:
if (skip_cutscene_label == null):
skip_cutscene_label = preload("res://SkipCutsceneLabel.tscn").instance();
self.add_child(skip_cutscene_label);
var progressbar = skip_cutscene_label.get_node("ProgressBar");
progressbar.value += delta;
if (progressbar.value >= progressbar.max_value):
begin_the_end();
end_timer_max = 1.0;
func reset_skip_cutscene_label() -> void:
if (skip_cutscene_label != null):
skip_cutscene_label.queue_free();
skip_cutscene_label = null;
func play_sound(sound: String) -> void:
gamelogic.play_sound(sound);
func change_ghosts() -> void:
ghost_type = 2;
ghost_timer = 0;
ghost_timer_max = 0.5;
func afterimage(sprite: Sprite, color: Color) -> void:
var afterimage = preload("res://Afterimage.tscn").instance();
afterimage.actor = sprite;
afterimage.set_material(gamelogic.get_afterimage_material_for(color));
$CutsceneHolder/Panel6.add_child(afterimage);
afterimage.scale = sprite.scale;
afterimage.rotation_degrees = sprite.rotation_degrees;
afterimage.get_child(0).centered = sprite.centered;
func ghost(sprite: Sprite) -> void:
var ghost = Sprite.new();
ghost.script = preload("res://GhostSprite.gd");
ghost.position = sprite.position;
ghost.target = sprite;
ghost.texture = sprite.texture;
ghost.centered = sprite.centered;
ghost.scale = sprite.scale;
ghost.rotation_degrees = sprite.rotation_degrees;
$CutsceneHolder/Panel6.add_child(ghost);
func destroy() -> void:
self.queue_free();
gamelogic.ui_stack.erase(self);
func _input(event: InputEvent) -> void:
if cutscene_step > 0:
if event is InputEventScreenTouch:
if event.pressed:
cutscene_step();
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
cutscene_step_cooldown += delta;
if (ghost_type == 1):
ghost_timer += delta;
if (ghost_timer > ghost_timer_max):
ghost_timer -= ghost_timer_max;
afterimage($CutsceneHolder/HeavyActor, gamelogic.heavy_color);
afterimage($CutsceneHolder/LightActor, gamelogic.light_color);
elif (ghost_type == 2):
ghost_timer += delta;
if (ghost_timer > ghost_timer_max):
ghost_timer -= ghost_timer_max;
ghost($CutsceneHolder/HeavyActor);
ghost($CutsceneHolder/LightActor);
if (cutscene_step > 0):
if (cutscene_step == 6 and cutscene_step_cooldown > 3.0):
cutscene_step();
if (cutscene_step == 7 and !$CutsceneHolder/AnimationPlayer.is_playing()):
advance_label();
if (cutscene_step < 6 and cutscene_step_cooldown > 4.0):
advance_label();
if (Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("character_switch")
or Input.is_action_just_pressed("lmb")):
cutscene_step();
elif (Input.is_action_pressed("escape") and end_timer_max == 0.0):
skip_cutscene_label_grows(delta);
else:
reset_skip_cutscene_label();
if (Input.is_action_just_pressed("any_controller") or Input.is_action_just_pressed("any_controller_2")):
using_controller = true;
only_mouse = false;
disclaimer.visible = false;
if Input.is_action_just_pressed("any_keyboard"):
using_controller = false;
only_mouse = false;
disclaimer.visible = false;
if (end_timer_max > 0):
if (Input.is_action_pressed("escape")):
end_timer += delta*3;
else:
end_timer += delta;
if (end_timer >= end_timer_max):
destroy();
else:
self.modulate = Color(1, 1, 1, ((end_timer_max-end_timer)/end_timer_max));
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
pointer.visible = false;
return;
if (pointer != null):
pointer.visible = true;
var focus = holder.get_focus_owner();
if (focus == null):
beginbutton.grab_focus();
focus = beginbutton;
var focus_middle_x = focus.rect_position.x + focus.rect_size.x / 2;
pointer.position.y = focus.rect_position.y + focus.rect_size.y / 2;
if (focus_middle_x > holder.rect_size.x / 2):
pointer.texture = preload("res://assets/tutorial_arrows/LeftArrow.tres");
pointer.position.x = focus.rect_position.x + focus.rect_size.x + 12;
else:
pointer.texture = preload("res://assets/tutorial_arrows/RightArrow.tres");
pointer.position.x = focus.rect_position.x - 12;