-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameMaster.gd
49 lines (32 loc) · 903 Bytes
/
GameMaster.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
extends Node
@export var levels : Array[PackedScene] = []
@export var location : int = 0 :
set(value):
value = min(15, value)
value = max(0, value)
location = value
@onready var level = get_node("Level")
func load_level(level_value : int):
## Destroy old level
level.queue_free()
var new_curr_level = levels[level_value].instantiate()
add_child(new_curr_level)
level = new_curr_level
new_curr_level.get_node("Player").connect("win_game", win_level )
func _unhandled_input(event):
if event.is_action_pressed("Reset"):
reset_level()
if event.is_action_pressed("next_level"):
win_level()
elif event.is_action("previous_level"):
location -= 1
reset_level()
func reset_level():
$Node/Reset.play()
load_level(location)
func win_level():
location += 1
$Node/Win.play()
load_level(location)
func _on_player_win_game():
pass # Replace with function body.