-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLevelManager.gd
More file actions
42 lines (36 loc) · 901 Bytes
/
LevelManager.gd
File metadata and controls
42 lines (36 loc) · 901 Bytes
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
extends Node2D
const Title = preload("res://Title.tscn")
const Credits = preload("res://Credits.tscn")
const Level1 = preload("res://Levels/Level1.tscn")
const Level2 = preload("res://Levels/Level2.tscn")
const Level3 = preload("res://Levels/Level3.tscn")
const Level5 = preload("res://Levels/Level5.tscn")
var current
var child
var queue = [
Title,
Level1,
Level5,
Level2,
Level3,
Credits
]
func _init():
current = queue.pop_front()
start_phase()
func start_phase():
var prev = child
child = current.instance()
child.connect("done", self, "on_phase_done")
child.connect("enter_debug", self, "on_enter_debug")
if prev:
child.connect("ready", self, "remove_child", [prev])
add_child(child)
func on_phase_done():
if queue.size() > 0:
current = queue.pop_front()
start_phase()
else:
get_tree().quit()
func on_enter_debug():
get_tree().change_scene("res://BootLoader.tscn")