diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-10-20 12:09:48 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-10-20 12:09:48 +0200 |
commit | 6db6465d1b938ec494cd66c9984bff5cc14bde11 (patch) | |
tree | 9533b364e3e40ff813ef263ab05bd69ac31f8777 /Towers | |
parent | e82990eeafdf0be5d42d8aaa9b7fb6091e0d8435 (diff) |
next commit
Diffstat (limited to 'Towers')
-rw-r--r-- | Towers/Tower.gd | 68 | ||||
-rw-r--r-- | Towers/Tower.tscn | 44 |
2 files changed, 60 insertions, 52 deletions
diff --git a/Towers/Tower.gd b/Towers/Tower.gd index 30af802..7eb8bf6 100644 --- a/Towers/Tower.gd +++ b/Towers/Tower.gd @@ -13,13 +13,12 @@ var is_selected = false : if value: if not Tower.selected_towers.has(self): Tower.selected_towers.append(self) - selected.emit() + selected.emit() else: Tower.selected_towers.erase(self) deselected.emit() is_selected = value queue_redraw() - toggle_ui() var is_hovered = false : set(value): @@ -51,7 +50,10 @@ func _ready(): $Range/CollisionShape2D.shape.radius = attack_range $ShootCooldown.wait_time = attack_speed - toggle_ui() + %Data.text = "Range: %s - Power: %s - Speed: %s" % [ + attack_range, attack_power, attack_speed + ] + #for component in [ #preload("res://Towers/Components/FrostComponent.gd").new(), @@ -61,16 +63,9 @@ func _ready(): func _draw(): - if is_selected: - draw_circle( - Client.current_stage.map.tile_set.tile_size, - 8 + attack_range, - Color(1, 1, 1, 0.75), - false, - 1.0 - ) - modulate = Color(1.5, 1.5, 1.5) - elif is_hovered: + modulate = Color(1, 1, 1) + + if is_hovered: if Client.state is StateDefault: draw_circle( Client.current_stage.map.tile_set.tile_size, @@ -80,8 +75,9 @@ func _draw(): 1.0 ) modulate = Color(1.25, 1.25, 1.25) - else: - modulate = Color(1, 1, 1) + + if is_selected: + modulate = Color(1.5, 1.5, 1.5) func _process(_delta: float) -> void: @@ -126,16 +122,13 @@ func _on_selectable_area_select(event: InputEvent) -> void: return if Client.state is StateDefault: - Client.select_tower(self) - - if event.is_double_click(): - var selection_area = preload("res://Game/Selection/MultiSelectArea.tscn").instantiate() - selection_area.set_collision_mask_value(3, true) - selection_area.select.connect(func(nodes): - for node in nodes: - Client.select_tower(node) - ) - get_tree().current_scene.add_child(selection_area) + if Input.is_action_pressed("select_multiple") and is_selected: + is_selected = false + else: + Client.select_tower(self) + + if event.is_double_click(): + Client.multi_select(3) @@ -182,8 +175,8 @@ func shoot(): target.set_hp(target.hp - 1) -func toggle_ui(): - $HUD.visible = is_selected +func get_hud(): + return %HUD.get_child(0).duplicate() func get_region(): @@ -200,15 +193,6 @@ func _on_tree_exiting() -> void: is_selected = false -func get_rpc_properties() -> Dictionary: - return { - "name": null, - "global_position": null, - "owner_id": null, - "attack_range": null, - } - - func _on_h_box_container_gui_input(event: InputEvent) -> void: if event.is_action_pressed("select"): get_viewport().set_input_as_handled() @@ -251,6 +235,10 @@ class NetworkData extends Resource: var name: String var owner_id: int var position: Vector2 + + var attack_range: int + var attack_power: int + var attack_speed: int var components: Array var sprite_modulate: Color @@ -262,6 +250,10 @@ func to_network_data() -> NetworkData: data.name = name data.owner_id = owner_id data.position = global_position + + data.attack_range = attack_range + data.attack_power = attack_power + data.attack_speed = attack_speed data.components = components.map(func(item: TowerComponent): return item.name ) @@ -289,4 +281,8 @@ static func from_network_data(data: NetworkData) -> Tower: tower.owner_id = data.owner_id tower.global_position = data.position + tower.attack_range = data.attack_range + tower.attack_power = data.attack_power + tower.attack_speed = data.attack_speed + return tower diff --git a/Towers/Tower.tscn b/Towers/Tower.tscn index 43c3c35..55ae928 100644 --- a/Towers/Tower.tscn +++ b/Towers/Tower.tscn @@ -71,43 +71,55 @@ shape = SubResource("RectangleShape2D_312i7") position = Vector2(0, 32) [node name="HUD" type="CanvasLayer" parent="."] - -[node name="CenterContainer" type="CenterContainer" parent="HUD"] -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 +unique_name_in_owner = true +visible = false + +[node name="VBoxContainer" type="VBoxContainer" parent="HUD"] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -38.0 +offset_top = -25.0 +offset_right = 38.0 +offset_bottom = 25.0 grow_horizontal = 2 -grow_vertical = 0 +grow_vertical = 2 + +[node name="Data" type="Label" parent="HUD/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 -[node name="VBoxContainer" type="VBoxContainer" parent="HUD/CenterContainer"] +[node name="Components" type="VBoxContainer" parent="HUD/VBoxContainer"] +unique_name_in_owner = true layout_mode = 2 -[node name="HBoxContainer" type="HBoxContainer" parent="HUD/CenterContainer/VBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="HUD/VBoxContainer/Components"] layout_mode = 2 mouse_default_cursor_shape = 2 -[node name="TextureRect" type="TextureRect" parent="HUD/CenterContainer/VBoxContainer/HBoxContainer"] +[node name="TextureRect" type="TextureRect" parent="HUD/VBoxContainer/Components/HBoxContainer"] custom_minimum_size = Vector2(32, 0) layout_mode = 2 texture = ExtResource("4_ccrqc") stretch_mode = 5 -[node name="Label" type="Label" parent="HUD/CenterContainer/VBoxContainer/HBoxContainer"] +[node name="Label" type="Label" parent="HUD/VBoxContainer/Components/HBoxContainer"] layout_mode = 2 text = "Frost" -[node name="HBoxContainer2" type="HBoxContainer" parent="HUD/CenterContainer/VBoxContainer"] +[node name="HBoxContainer2" type="HBoxContainer" parent="HUD/VBoxContainer/Components"] layout_mode = 2 mouse_default_cursor_shape = 2 -[node name="TextureRect" type="TextureRect" parent="HUD/CenterContainer/VBoxContainer/HBoxContainer2"] +[node name="TextureRect" type="TextureRect" parent="HUD/VBoxContainer/Components/HBoxContainer2"] custom_minimum_size = Vector2(32, 0) layout_mode = 2 texture = ExtResource("5_y7tf5") stretch_mode = 5 -[node name="Label" type="Label" parent="HUD/CenterContainer/VBoxContainer/HBoxContainer2"] +[node name="Label" type="Label" parent="HUD/VBoxContainer/Components/HBoxContainer2"] layout_mode = 2 text = "Burn" @@ -121,5 +133,5 @@ replication_config = SubResource("SceneReplicationConfig_spp26") [connection signal="hover_enter" from="SelectableArea" to="." method="_on_selectable_area_hover_enter"] [connection signal="hover_exit" from="SelectableArea" to="." method="_on_selectable_area_hover_exit"] [connection signal="select" from="SelectableArea" to="." method="_on_selectable_area_select"] -[connection signal="gui_input" from="HUD/CenterContainer/VBoxContainer/HBoxContainer" to="." method="_on_h_box_container_gui_input"] -[connection signal="gui_input" from="HUD/CenterContainer/VBoxContainer/HBoxContainer2" to="." method="_on_h_box_container_2_gui_input"] +[connection signal="gui_input" from="HUD/VBoxContainer/Components/HBoxContainer" to="." method="_on_h_box_container_gui_input"] +[connection signal="gui_input" from="HUD/VBoxContainer/Components/HBoxContainer2" to="." method="_on_h_box_container_2_gui_input"] |