blob: 6eeb7da42472b562d315ed3652272d5b09134236 (
plain)
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
101
102
103
104
|
class_name HUD
extends CanvasLayer
@onready var time: Label = %Time
@onready var money: Label = %Money
@onready var income: Label = %Income
@onready var spawn_box: Control = %SpawnBox
@onready var team_top: PanelContainer = %TeamTop
@onready var team_bottom: PanelContainer = %TeamBottom
@onready var lives_top: Label = %LivesTop
@onready var lives_bottom: Label = %LivesBottom
func _ready():
Client.player.money_changed.connect(func():
money.text = "Money: " + str(Client.player.money)
)
Client.player.income_changed.connect(func():
income.text = "Income: " + str(Client.player.income)
)
Client.current_stage.lives_changed.connect(func():
lives_top.text = "Lives: %02d" % Client.current_stage.teams.top.lives
lives_bottom.text = "Lives: %02d" % Client.current_stage.teams.bottom.lives
)
Client.stage_state_changed.connect(func(state: State):
if state is StateBuild:
%TowerConfigurationsContainer.visible = true
else:
%TowerConfigurationsContainer.visible = false
)
# TODO: fix multi select
%SelectionContainer.visible = false
%SelectionData.get_child(0).queue_free()
%MultiSelectionContainer.visible = false
Client.placed_tower.connect(func(tower: Tower):
tower.selected.connect(func():
var hud_data = tower.get_hud()
hud_data.name = tower.name
var groups = {"md5:1": [], "md5_2": []}
var selected_group = "md5"
# TODO: build groups from current component configurations matches. md5 of property values?
# TODO: do in tower.gd at select?
if Tower.selected_towers.size() == 1:
%SelectionContainer.visible = true
%MultiSelectionContainer.visible = false
%SelectionData.add_child(hud_data)
%MultiSelectionList.add_child(hud_data.duplicate())
elif Tower.selected_towers.size() > 1:
%SelectionContainer.visible = false
%MultiSelectionContainer.visible = true
%MultiSelectionList.add_child(hud_data)
)
tower.deselected.connect(func():
if Tower.selected_towers.size() == 0:
%SelectionContainer.visible = false
%MultiSelectionContainer.visible = false
for child in %SelectionData.get_children():
child.queue_free()
for child in %MultiSelectionList.get_children():
child.queue_free()
elif Tower.selected_towers.size() == 1:
%MultiSelectionContainer.visible = false
%SelectionContainer.visible = true
elif Tower.selected_towers.size() > 1:
# only remove deselected tower from list
%MultiSelectionList.get_node(NodePath(tower.name)).queue_free()
)
)
func _input(event: InputEvent):
if event.is_action_pressed("spawn_box_toggle"):
spawn_box.visible = not spawn_box.visible
if event.is_action_pressed("players_list_toggle"):
team_top.visible = not team_top.visible
team_bottom.visible = not team_bottom.visible
func _on_build_mode_button_gui_input(event: InputEvent) -> void:
if event.is_action_pressed("select"):
if Client.state is StateDefault:
get_tree().current_scene.get_node("StateManager").set_state("StateBuild")
elif Client.state is StateBuild:
get_tree().current_scene.get_node("StateManager").set_state("StateDefault")
func _on_spawner_box_button_gui_input(event: InputEvent) -> void:
if event.is_action_pressed("select"):
spawn_box.visible = not spawn_box.visible
func _on_player_list_button_gui_input(event: InputEvent) -> void:
if event.is_action_pressed("select"):
team_top.visible = not team_top.visible
team_bottom.visible = not team_bottom.visible
|