blob: b6722ae9a53fd6996ea1c895b21c63281f9808fc (
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
|
class_name HUD
extends CanvasLayer
@onready var money: Label = %Money
@onready var income: Label = %Income
@onready var tower: Label = %Tower
@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
)
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
|