diff options
Diffstat (limited to 'Stages/Wintermaul/HUD.gd')
-rw-r--r-- | Stages/Wintermaul/HUD.gd | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 62a5abd..b9b831f 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -2,6 +2,10 @@ class_name HUD extends CanvasLayer +@export var selection_manager: SelectionManager +@export var money_manager: MoneyManager +@export var notification_manager: NotificationManager + @onready var time: Label = %Time @onready var money: Label = %Money @onready var income: Label = %Income @@ -11,6 +15,8 @@ extends CanvasLayer @onready var lives_top: Label = %LivesTop @onready var lives_bottom: Label = %LivesBottom +@onready var status_messages: Control = %StatusMessages + func _ready(): Client.player.money_changed.connect(func(): @@ -37,7 +43,7 @@ func _ready(): %MultiSelectionContainer.visible = false # add tower to selection - Client.selection.added_to_group.connect(func(nodes: Array[Node], id: String): + selection_manager.added_to_group.connect(func(nodes: Array[Node], id: String): for tower: Tower in nodes: var multi_select_hud_data = TextureRect.new() multi_select_hud_data.modulate = Color(0.5, 0.5, 0.5) @@ -55,11 +61,11 @@ func _ready(): multi_select_hud_data.add_to_group(id) %MultiSelectionList.add_child(multi_select_hud_data) - if Client.selection.node_count == 1: + if selection_manager.node_count == 1: %SelectionContainer.visible = true %MultiSelectionContainer.visible = false - elif Client.selection.node_count > 1: + elif selection_manager.node_count > 1: %MultiSelectionContainer.visible = true redraw_multiselect() @@ -67,13 +73,13 @@ func _ready(): ) # remove tower from selection - Client.selection.removed_from_group.connect(func(nodes: Array[Node], _id: String): + selection_manager.removed_from_group.connect(func(nodes: Array[Node], _id: String): for tower: Tower in nodes: - if Client.selection.node_count == 0: + if selection_manager.node_count == 0: %SelectionContainer.visible = false %MultiSelectionContainer.visible = false - elif Client.selection.node_count == 1: + elif selection_manager.node_count == 1: %MultiSelectionContainer.visible = false %SelectionContainer.visible = true @@ -85,22 +91,26 @@ func _ready(): ) # move tower to new selection group - Client.selection.moved_to_group.connect(func(nodes: Array[Node], previous_id: String, new_id: String): + selection_manager.moved_to_group.connect(func(nodes: Array[Node], previous_id: String, new_id: String): for tower: Tower in nodes: tower.get_meta("multi_select_hud").remove_from_group(previous_id) tower.get_meta("multi_select_hud").add_to_group(new_id) - if Client.selection.has_node_in_group(tower, new_id): + if selection_manager.has_node_in_group(tower, new_id): redraw_select(tower) redraw_multiselect(previous_id, new_id) ) # redraw on selected group change - Client.selection.selected_group_changed.connect(func(previous_id: String, new_id: String): - if Client.selection.get_selected_nodes(): - redraw_select(Client.selection.get_selected_nodes()[0]) + selection_manager.selected_group_changed.connect(func(previous_id: String, new_id: String): + if selection_manager.get_selected_nodes(): + redraw_select(selection_manager.get_selected_nodes()[0]) redraw_multiselect(previous_id, new_id) ) + + %TowerData.selection_manager = selection_manager + %TowerData.money_manager = money_manager + %TowerData.notification_manager = notification_manager func _input(event: InputEvent): @@ -112,19 +122,19 @@ func _input(event: InputEvent): if event.is_action_pressed("selection_cycle") and %MultiSelectionContainer.visible: if Input.is_action_pressed("reverse_cycle_direction"): - Client.selection.go_to_previous() + selection_manager.go_to_previous() else: - Client.selection.go_to_next() + selection_manager.go_to_next() func redraw_select(tower: Tower): %TowerData.current_tower = tower -func redraw_multiselect(previous_group: String = "", new_group: String = Client.selection.selected_group): +func redraw_multiselect(previous_group: String = "", new_group: String = selection_manager.selected_group): var idx = 0 - for id in Client.selection.get_ordered_group_ids(): - var group = Client.selection.selection_groups[id] + for id in selection_manager.get_ordered_group_ids(): + var group = selection_manager.selection_groups[id] for node: Tower in group: # when double click selecting in quick succession not found error if (node.has_meta("multi_select_hud") and |