blob: 023f157f4fbbeb6478964658993e81f688e778f6 (
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
|
class_name HUD
extends CanvasLayer
@onready var score: Label = %Score
@onready var tower: Label = %Tower
@onready var spawn_box: Control = %SpawnBox
@onready var players_list: PanelContainer = %PlayersList
func _ready():
Client.player.score_changed.connect(func():
score.text = str(Client.player.score)
)
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"):
players_list.visible = not players_list.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"):
players_list.visible = not players_list.visible
|