-
Notifications
You must be signed in to change notification settings - Fork 1
/
CrtManager.gd
171 lines (157 loc) · 5.77 KB
/
CrtManager.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
class_name CRT extends Node
@export var exit : ExitManager
var viewing = false
@export var intro : IntroManager
@export var bathroom_normal : VisualInstance3D
@export var bathroom_broken : VisualInstance3D
@export var mask : Node3D
@export var objarray_normal : Array[Node3D]
@export var objarray_broken : Array[Node3D]
@export var anim_intro : AnimationPlayer
@export var array_bootup : Array[Node3D]
@export var array_bootuplogo : Array[Node3D]
@export var array_partbranch : Array[PartitionBranch]
@export var array_stats : Array[Node3D]
@export var screenparent_leaderboard : Node3D
@export var screenparent_stats : Node3D
var window_index = 3
@export var iconbranches : Array[CrtIcon]
@export var anim_iconfade : AnimationPlayer
@export var board : Board
@export var speaker_playerwalk : AudioStreamPlayer2D
@export var speaker_bootuploop : AudioStreamPlayer2D
@export var speaker_shutdown : AudioStreamPlayer2D
@export var speaker_consolebeep : AudioStreamPlayer2D
@export var speaker_buttonpress : AudioStreamPlayer2D
@export var speaker_navbeep : AudioStreamPlayer2D
@export var speaker_melody : AudioStreamPlayer2D
@export var speaker_melodyhide : AudioStreamPlayer2D
var selection_range1 = 1
var selection_range2 = 12
func _ready():
screenparent_stats.visible = true
screenparent_leaderboard.visible = false
func _unhandled_input(event):
if (event.is_action_pressed("ui_accept") && viewing):
Interaction("window")
if (event.is_action_pressed("ui_cancel") && viewing):
Interaction("exit")
if (event.is_action_pressed("exit game") && viewing):
Interaction("exit")
if (event.is_action_pressed("ui_left") && viewing):
Interaction("left")
if (event.is_action_pressed("ui_right") && viewing):
Interaction("right")
func DisableCRT():
SetCRT(false)
func SetCRT(state : bool):
if (state && GlobalVariables.using_steam):
bathroom_normal.set_layer_mask_value(1, false)
bathroom_broken.visible = true
for obj in objarray_normal: obj.visible = false
for obj in objarray_broken: obj.visible = true
mask.visible = true
else:
bathroom_normal.set_layer_mask_value(1, true)
bathroom_broken.visible = false
for obj in objarray_normal: obj.visible = true
for obj in objarray_broken: obj.visible = false
mask.visible = false
@export var branch_right : InteractionBranch
@export var branch_left : InteractionBranch
@export var branch_window : InteractionBranch
@export var branch_exit : InteractionBranch
var has_exited = false
func Interaction(alias : String):
speaker_buttonpress.pitch_scale = randf_range(.8, 1)
speaker_buttonpress.play()
match alias:
"right":
branch_right.get_parent().get_child(1).Press()
if (selection_range2 <= board.active_entry_count && window_index == 0):
selection_range1 += 12
selection_range2 += 12
if (window_index == 0): board.DownloadEntries(selection_range1, selection_range2, "top")
"left":
branch_left.get_parent().get_child(1).Press()
if (selection_range1 != 1 && window_index == 0):
selection_range1 -= 12
selection_range2 -= 12
if (window_index == 0): board.DownloadEntries(selection_range1, selection_range2, "top")
"window":
branch_window.get_parent().get_child(1).Press()
CycleWindow()
"exit":
has_exited = true
branch_exit.get_parent().get_child(1).Press()
viewing = false
board.TurnOffDisplay()
intro.DisableInteractionCrt()
await get_tree().create_timer(.3, false).timeout
intro.RevertCRT()
exit.exitAllowed = true
func CycleWindow():
board.lock.material_override.albedo_color = Color(1, 1, 1, 0)
selection_range1 = 1
selection_range2 = 12
board.ClearDisplay()
window_index += 1
if window_index == 4: window_index = 0
for icon in iconbranches: icon.CheckState(window_index)
if (window_index == 3):
board.nocon.visible = false
screenparent_leaderboard.visible = false
screenparent_stats.visible = true
else:
screenparent_leaderboard.visible = true
screenparent_stats.visible = false
board.nocon.visible = true
if (window_index == 0): board.PassLeaderboard(selection_range1, selection_range2, "top")
if (window_index == 1):
board.lock.visible = true
board.PassLeaderboard(selection_range1, selection_range2, "overview")
if (window_index == 2): board.PassLeaderboard(1, 49, "friends") #range ignored
func Bootup():
has_exited = false
board.lock.material_override.albedo_color = Color(1, 1, 1, 0)
screenparent_stats.visible = true
board.UpdateStats()
window_index = 3
for icon in iconbranches: icon.CheckState(window_index)
for line in array_bootup:
line.visible = true
await get_tree().create_timer(.07, false).timeout
speaker_navbeep.pitch_scale = randf_range(1, 1)
speaker_navbeep.play()
await get_tree().create_timer(.1, false).timeout
for part in array_partbranch:
part.Loop(true)
await get_tree().create_timer(.04, false).timeout
speaker_navbeep.pitch_scale = randf_range(.1, .1)
speaker_navbeep.play()
await get_tree().create_timer(1, false).timeout
for part in array_partbranch: part.Loop(false)
await get_tree().create_timer(1, false).timeout
for line in array_bootup: line.visible = false
await get_tree().create_timer(.2, false).timeout
speaker_melody.pitch_scale = 2
speaker_melody.play()
for line in array_bootuplogo:
line.visible = true
await get_tree().create_timer(.07, false).timeout
await get_tree().create_timer(2, false).timeout
for line in array_bootuplogo: line.visible = false
speaker_melody.stop()
speaker_melodyhide.play()
await get_tree().create_timer(.5, false).timeout
anim_iconfade.play("fade in")
await get_tree().create_timer(.5, false).timeout
for i in array_stats:
i.visible = true
await get_tree().create_timer(.07, false).timeout
speaker_navbeep.pitch_scale = randf_range(.5, .5)
speaker_navbeep.play()
await get_tree().create_timer(.3, false).timeout
intro.EnabledInteractionCRT()
exit.exitAllowed = false
viewing = true