-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.gd
100 lines (75 loc) · 2.2 KB
/
game.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
extends Node2D
var menu_scene = preload("res://stages/menu.tscn")
var stage_progression = []
var current_stage
var tutorial_stage_progression = [
preload("res://stages/tutorial_1.tscn"),
preload("res://stages/tutorial_2.tscn"),
preload("res://stages/tutorial_3.tscn"),
]
var main_stage_progression = [
preload("res://stages/stage_1.tscn"),
preload("res://stages/stage_2.tscn"),
preload("res://stages/stage_3.tscn"),
preload("res://stages/stage_4.tscn"),
]
var testing_stage_progression = [
preload("res://stages/testing_area.tscn")
]
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
global.reset()
add_to_group("game_over")
add_to_group("goal")
add_to_group("stage")
add_to_group("stage_manager")
add_to_group("menu")
advance_stage()
get_tree().call_group("goal", "goal")
func _unhandled_input(event):
if event.is_action_pressed("ui_cancel"):
get_tree().quit()
func game_over():
music_to_wind()
yield(get_tree().create_timer(5.0), "timeout")
stage_progression = [menu_scene]
advance_stage()
func goal():
music_to_wind()
func music_to_wind():
$music.stop()
yield(get_tree().create_timer(2.0), "timeout")
$wind/tween.interpolate_property($wind, "volume_db", -30, $wind.volume_db, 5.0, Tween.TRANS_LINEAR, Tween.EASE_IN)
$wind/tween.start()
$wind.play()
func start_stage():
$wind.stop()
$music.play()
global.player_health = 100
func finish_stage():
advance_stage()
func start_tutorial():
stage_progression = tutorial_stage_progression.duplicate()
advance_stage()
func start_game():
global.reset()
stage_progression = main_stage_progression.duplicate()
advance_stage()
func start_testing():
global.ability_budget = 100
stage_progression = testing_stage_progression.duplicate()
advance_stage()
func advance_stage():
if not in_the_middle_of_a_transition():
$animation_player.play("transition")
yield(get_tree().create_timer(0.65), "timeout")
if current_stage:
current_stage.queue_free()
var next_stage_scene = stage_progression.pop_front()
if next_stage_scene:
current_stage = next_stage_scene.instance()
else:
current_stage = menu_scene.instance()
add_child(current_stage)
func in_the_middle_of_a_transition():
return $animation_player.is_playing()