diff options
Diffstat (limited to 'Stages/Wintermaul')
-rw-r--r-- | Stages/Wintermaul/HUD.gd | 151 | ||||
-rw-r--r-- | Stages/Wintermaul/HUD.tscn | 1 | ||||
-rw-r--r-- | Stages/Wintermaul/wintermaul.gd | 24 |
3 files changed, 90 insertions, 86 deletions
diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 1349bda..6063b18 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -41,94 +41,93 @@ func _ready(): %TowerConfigurationsContainer.visible = false ) - # TODO: fix multi select + # 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() - - var multi_select_hud_data = TextureRect.new() - multi_select_hud_data.name = tower.name - multi_select_hud_data.modulate = Color(0.5, 0.5, 0.5) - var texture = AtlasTexture.new() - texture.atlas = preload("res://core_outdoor.png") - texture.region = Rect2(400, 432, 32, 48) - multi_select_hud_data.texture = texture - - if not tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id] = [] - selection_groups[tower.selection_group_id].append(tower) - multi_select_hud_data.add_to_group(tower.selection_group_id) - - # TODO: build groups from current component configurations matches. md5 of property values? - # TODO: do in tower.gd at select? - # TODO: probably do here at the selected signal and add to groups var at top - - if Tower.selected_towers.size() == 1: - %SelectionContainer.visible = true - %MultiSelectionContainer.visible = false + if tower.owner_id == multiplayer.get_unique_id(): + tower.selected.connect(func(): + var hud_data = tower.get_hud() - redraw_select(hud_data) - %MultiSelectionList.add_child(multi_select_hud_data) - elif Tower.selected_towers.size() > 1: - %MultiSelectionContainer.visible = true + var multi_select_hud_data = TextureRect.new() + multi_select_hud_data.name = tower.name + multi_select_hud_data.modulate = Color(0.5, 0.5, 0.5) + var texture = AtlasTexture.new() + texture.atlas = preload("res://core_outdoor.png") + texture.region = Rect2(400, 432, 32, 48) + multi_select_hud_data.texture = texture - %MultiSelectionList.add_child(multi_select_hud_data) + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + multi_select_hud_data.add_to_group(tower.selection_group_id) - redraw_multiselect("", selected_group) - ) - - 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 - %MultiSelectionList.get_node(NodePath(tower.name)).queue_free() - elif Tower.selected_towers.size() > 1: - # only remove deselected tower from list - var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name)) - if node: # when double click selecting in quick succession not found error - node.queue_free() + if Tower.selected_towers.size() == 1: + %SelectionContainer.visible = true + %MultiSelectionContainer.visible = false + + redraw_select(hud_data) + %MultiSelectionList.add_child(multi_select_hud_data) + elif Tower.selected_towers.size() > 1: + %MultiSelectionContainer.visible = true + + %MultiSelectionList.add_child(multi_select_hud_data) + + redraw_multiselect("", selected_group) + ) - if tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id].erase(tower) - if selection_groups[tower.selection_group_id].is_empty(): - selection_groups.erase(tower.selection_group_id) - ) - - tower.selection_group_id_changed.connect(func(previous_id: String): - if not tower.selection_group_id in selection_groups: - selection_groups[tower.selection_group_id] = [] - selection_groups[tower.selection_group_id].append(tower) - %MultiSelectionList.get_node(NodePath(tower.name)).add_to_group(tower.selection_group_id) + 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 + %MultiSelectionList.get_node(NodePath(tower.name)).queue_free() + elif Tower.selected_towers.size() > 1: + # only remove deselected tower from list + var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name)) + if node: # when double click selecting in quick succession not found error + node.queue_free() + + if tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id].erase(tower) + if selection_groups[tower.selection_group_id].is_empty(): + selection_groups.erase(tower.selection_group_id) + ) - selection_groups[previous_id].erase(tower) - if selection_groups[previous_id].is_empty(): - selection_groups.erase(previous_id) - if previous_id == selected_group: - selected_group = tower.selection_group_id - %MultiSelectionList.get_node(NodePath(tower.name)).remove_from_group(previous_id) + tower.selection_group_id_changed.connect(func(previous_id: String): + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + %MultiSelectionList.get_node(NodePath(tower.name)).add_to_group(tower.selection_group_id) + + selection_groups[previous_id].erase(tower) + if selection_groups[previous_id].is_empty(): + selection_groups.erase(previous_id) + if previous_id == selected_group: + selected_group = tower.selection_group_id + %MultiSelectionList.get_node(NodePath(tower.name)).remove_from_group(previous_id) + + if tower.name == selection_groups[tower.selection_group_id][0].name: + redraw_select(tower.get_hud()) + ) - if tower.name == selection_groups[tower.selection_group_id][0].name: - redraw_select(tower.get_hud()) - ) - - tower.attack_value_changed.connect(func(value: int): - attack_value_changed.emit(value) - ) + tower.attack_value_changed.connect(func(value: int): + attack_value_changed.emit(value) + ) ) Client.multi_select_finished.connect(func(): - selected_group = get_ordered_group_keys()[0] + var keys = get_ordered_group_keys() + if keys.size() > 0: + selected_group = keys[0] ) @@ -164,8 +163,10 @@ func redraw_multiselect(previous_group: String, new_group: String): for node in get_tree().get_nodes_in_group(previous_group): node.modulate = Color(0.5, 0.5, 0.5) + Client.current_stage.get_node("%Towers/" + node.name).is_highlighted = false for node in get_tree().get_nodes_in_group(new_group): node.modulate = Color(1.0, 1.0, 1.0) + Client.current_stage.get_node("%Towers/" + node.name).is_highlighted = true func get_ordered_group_keys() -> Array: diff --git a/Stages/Wintermaul/HUD.tscn b/Stages/Wintermaul/HUD.tscn index 52dde03..279c967 100644 --- a/Stages/Wintermaul/HUD.tscn +++ b/Stages/Wintermaul/HUD.tscn @@ -40,7 +40,6 @@ action = &"spawn_unit" events = [SubResource("InputEventAction_t6x4q")] [node name="HUD" type="CanvasLayer"] -visible = false script = ExtResource("1_2bu0v") [node name="Panel" type="PanelContainer" parent="."] diff --git a/Stages/Wintermaul/wintermaul.gd b/Stages/Wintermaul/wintermaul.gd index 9219a29..e66a979 100644 --- a/Stages/Wintermaul/wintermaul.gd +++ b/Stages/Wintermaul/wintermaul.gd @@ -40,8 +40,8 @@ func _ready(): }) # set camera limits - $Camera.limit_left = $Map.get_used_rect().position.x * %Map.tile_set.tile_size.x - $Camera.limit_right = $Map.get_used_rect().end.x * %Map.tile_set.tile_size.x + $Camera.limit_left = $Map.get_used_rect().position.x * %Map.tile_set.tile_size.x - %Map.tile_set.tile_size.x + $Camera.limit_right = $Map.get_used_rect().end.x * %Map.tile_set.tile_size.x - %Map.tile_set.tile_size.x $Camera.limit_top = %Map.get_used_rect().position.y * %Map.tile_set.tile_size.y $Camera.limit_bottom = %Map.get_used_rect().end.y * %Map.tile_set.tile_size.y @@ -87,8 +87,9 @@ func place_tower(remote_data: Dictionary): var player = Network.get_player(tower.owner_id) player.towers[tower.global_position] = tower - if multiplayer.is_server(): - Network.update_player.rpc(player.id, {"money": -5}) + player.money -= 5 + Network.players_changed.emit() + #Network.update_player.rpc(player.id, {"money": -5}) _place_tower(%Towers, tower) Client.placed_tower.emit(tower) @@ -111,12 +112,15 @@ func spawn_unit(remote_data: Dictionary): update_lives.rpc("top", -1) ) - Network.update_player.rpc(player.id, { - "money": -5, - "income": 1, - }) - - _spawn_unit(%Units, unit) + #Network.update_player.rpc(player.id, { + #"money": -5, + #"income": 1, + #}) + player.money -= 5 + player.income += 1 + Network.players_changed.emit() + + _spawn_unit(%Towers, unit) func can_place_tower(): |