-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.gd
46 lines (39 loc) · 1.33 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
extends Node2D
const maps : Array[PackedScene] = [
preload("res://resources/map scenes/1.tscn"),
preload("res://resources/map scenes/0.tscn"),
preload("res://resources/map scenes/2.tscn"),
preload("res://resources/map scenes/3.tscn"),
preload("res://resources/map scenes/4.tscn"),
preload("res://resources/map scenes/6.tscn"),
preload("res://resources/map scenes/7.tscn"),
preload("res://resources/map scenes/8.tscn"),
preload("res://resources/map scenes/9.tscn"),
]
@onready var animation_player: AnimationPlayer = $CanvasLayer3/AnimationPlayer
var tutorial_map = preload("res://resources/map scenes/tutorial.tscn")
var inst: Node2D
@onready var UI = $CanvasLayer2
func _ready() -> void:
tutorial()
PlayerStats.player_died.connect(_on_player_died)
func tutorial() -> void:
EnemySpawner.active = false
UI.visible = false
inst = tutorial_map.instantiate()
add_child(inst)
MusicManager.transition(&"Battle", &"Upgrade", 0.5)
func reload() -> void:
UI.visible = true
if inst != null:
inst.queue_free()
inst = maps.pick_random().instantiate()
add_child(inst)
MusicManager.transition(&"Upgrade", &"Battle", 0.5)
EnemySpawner.wave = 0
EnemySpawner.active = true
EnemySpawner.wave_started = false
func _on_player_died() -> void:
animation_player.play(&"end")
await animation_player.animation_finished
get_tree().reload_current_scene()