-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.gd
129 lines (109 loc) · 5.08 KB
/
main.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
extends Node
const GUI = preload("res://menus/gui.gd")
const Package = preload("res://package/package.gd")
const Phone = preload("res://level/phone.gd")
const StoreOpener = preload("res://store_opener/store_opener.gd")
const QuitJobButton = preload("res://quit_job/quit_job_button.gd")
@onready var gui := $GUI
@onready var world := $World
@onready var player := $World/Player
var can_pause := false
const SKIP_MAIN_MENU := false
const SKIP_TUTORIAL := false
var day = 0
func _ready():
get_tree().paused = true
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
gui.set_mouse_sensitivity(player.mouse_sensitivity)
if SKIP_MAIN_MENU:
gui._on_main_menu_screen_game_started()
func _input(event):
if event.is_action_pressed("pause") and can_pause:
gui.show_pause_screen()
get_tree().paused = true
elif event.is_action_pressed("skip_day"):
_on_world_day_ended(10, 59)
func _process(delta):
if player.held_object != null:
gui.set_cursor(GUI.Cursor.CLOSED_HAND, 'Rotate')
elif is_instance_valid(player.hovered_object) and player.hovered_object is Package:
gui.set_cursor(GUI.Cursor.OPEN_HAND, 'Grab')
elif is_instance_valid(player.hovered_object) and player.hovered_object is Phone and player.hovered_object.is_ringing():
gui.set_cursor(GUI.Cursor.OPEN_HAND, 'Pick Up')
elif is_instance_valid(player.hovered_object) and player.hovered_object is StoreOpener:
if player.hovered_object.can_open_store():
gui.set_cursor(GUI.Cursor.OPEN_HAND, 'Open Store')
elif not player.hovered_object.is_store_open():
gui.set_cursor(GUI.Cursor.DISALLOW, 'Waiting For Packages')
else:
gui.set_cursor(GUI.Cursor.DOT, '')
elif is_instance_valid(player.hovered_object) and player.hovered_object is QuitJobButton:
gui.set_cursor(GUI.Cursor.OPEN_HAND, 'Quit Job')
else:
gui.set_cursor(GUI.Cursor.DOT, '')
func _on_gui_unpaused():
get_tree().paused = false
func start_game():
can_pause = true
get_tree().paused = false
world.start_day(day, SKIP_TUTORIAL)
func _on_gui_game_started():
start_game()
func _on_gui_mouse_sensitivity_changed(mouse_sensitivity):
player.mouse_sensitivity = mouse_sensitivity
func _on_gui_volume_changed(volume: float):
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), volume)
func _on_world_day_ended(packages: int, seconds: int):
await gui.fade_out()
gui.show_game_over_screen(packages, seconds)
await gui.game_over_screen_closed
day += 1
world.start_day(day)
await gui.fade_in()
var day_0_tutorial : Array[String] = [
"Hello?",
"Ah hello! Welcome to your first day at Personal Delivery Conglomerate™!",
"Sorry I couldn't be there in person today, I prefer to work from home most days.",
"I can't really show you the ropes too well over the phone but I'm sure you'll work things out.",
"You just need to take the packages that come in on the conveyor and store them on the shelves in the back.",
"Try to keep it organised back there, store them by size or shape or something.",
"You could also store them by delivery company based on the logo on the box.",
"Our logo is the blue man with the green hat.",
"This centre also receives packages on behalf of Logistics Corp and Ship 4 Less.",
"Once all the packages have come in, flip the switch to open the store.",
"Customers will start coming around to collect.",
"Make sure to check their ID to find out their name and address.",
"You can scan packages at the blue scanning machine in the back to see who they're for.",
"I'll give you a bigger bonus if you can give customers the right package quickly...",
"so that's why getting organised at the start of the day is so important.",
"Anyway, I've chatted your ear off enough. Get to work.",
"And remember, \"With Personal Delivery Conglomerate™, it's always personal®\" *click*",
]
var day_1_tutorial : Array[String] = [
"Hello again!",
"More of the same today.",
"It was a busy day, there'll be a few more packages so you'll really have to bring your organisational A-game.",
"Anyway, I'm sure you're itching to get started. Get to work.",
"And remember, \"With Personal Delivery Conglomerate™, it's always personal®\" *click*",
]
var day_2_tutorial : Array[String] = [
"Hello once more!",
"Good job delivering all the packages yesterday, you did an adequate job.",
"Listen, there may be a few more packages today...",
"Some of our delivery drivers heard that I had started working from home and followed suit.",
"And by some I mean all.",
"Anyway, I'm sure it's nothing you can't handle :). Get to work.",
"And remember, \"With Personal Delivery Conglomerate™, it's always personal®\" *click*",
]
func _on_world_phone_call_started():
match day:
0:
gui.show_call(day_0_tutorial)
1:
gui.show_call(day_1_tutorial)
2:
gui.show_call(day_2_tutorial)
await gui.call_ended
world.finish_call()
func _on_quit_job_button_job_quitted():
get_tree().quit()