-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgradeStation.gd
41 lines (30 loc) · 1.04 KB
/
UpgradeStation.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
extends Node3D
@onready
var player = $"../Player"
var enabled_upgrades: Array[Upgrade.Kind] = []
func _ready():
visible = false
GlobalSignals.level_up.connect(start_upgrading)
set_choosable_upgrades()
for chooser in get_children():
chooser.upgrade_chosen.connect(upgrade_chosen)
func set_choosable_upgrades():
var available = Upgrade.Kind.values().filter(func(kind): return Upgrade.can_get_upgrade(enabled_upgrades, kind))
available.shuffle()
for chooser in get_children():
var kind = available.pop_back()
if kind != null:
chooser.visible = true
chooser.kind = kind
else:
chooser.visible = false
func upgrade_chosen(upgrade: Upgrade.Kind):
for chooser in get_children():
chooser.get_node("Description").text = ""
await player.play_new_level_transition()
visible = false
enabled_upgrades.push_back(upgrade)
GlobalSignals.new_level_chosen.emit(upgrade)
set_choosable_upgrades()
func start_upgrading(_level: int):
visible = true