summaryrefslogtreecommitdiff
path: root/Towers
diff options
context:
space:
mode:
Diffstat (limited to 'Towers')
-rw-r--r--Towers/Assets/attack-component.pngbin0 -> 191 bytes
-rw-r--r--Towers/Assets/attack-component.png.import34
-rw-r--r--Towers/Assets/attack-component.png~bin0 -> 206 bytes
-rw-r--r--Towers/Assets/burn-component.pngbin0 -> 175 bytes
-rw-r--r--Towers/Assets/burn-component.png.import34
-rw-r--r--Towers/Assets/burn-component.png~bin0 -> 175 bytes
-rw-r--r--Towers/Assets/frost-component.pngbin0 -> 176 bytes
-rw-r--r--Towers/Assets/frost-component.png.import34
-rw-r--r--Towers/Assets/range-component.pngbin0 -> 162 bytes
-rw-r--r--Towers/Assets/range-component.png.import34
-rw-r--r--Towers/Assets/range-component.png~bin0 -> 176 bytes
-rw-r--r--Towers/Tower.gd70
-rw-r--r--Towers/Tower.tscn15
13 files changed, 186 insertions, 35 deletions
diff --git a/Towers/Assets/attack-component.png b/Towers/Assets/attack-component.png
new file mode 100644
index 0000000..bb9250c
--- /dev/null
+++ b/Towers/Assets/attack-component.png
Binary files differ
diff --git a/Towers/Assets/attack-component.png.import b/Towers/Assets/attack-component.png.import
new file mode 100644
index 0000000..ef9a73b
--- /dev/null
+++ b/Towers/Assets/attack-component.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://gbknvb38euuq"
+path="res://.godot/imported/attack-component.png-648f34932bc6754ec1b1094b76b170bc.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://Towers/Assets/attack-component.png"
+dest_files=["res://.godot/imported/attack-component.png-648f34932bc6754ec1b1094b76b170bc.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/Towers/Assets/attack-component.png~ b/Towers/Assets/attack-component.png~
new file mode 100644
index 0000000..e2f80bc
--- /dev/null
+++ b/Towers/Assets/attack-component.png~
Binary files differ
diff --git a/Towers/Assets/burn-component.png b/Towers/Assets/burn-component.png
new file mode 100644
index 0000000..33f9f7e
--- /dev/null
+++ b/Towers/Assets/burn-component.png
Binary files differ
diff --git a/Towers/Assets/burn-component.png.import b/Towers/Assets/burn-component.png.import
new file mode 100644
index 0000000..0783a55
--- /dev/null
+++ b/Towers/Assets/burn-component.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://2djpswd6sgng"
+path="res://.godot/imported/burn-component.png-c625b666f5c33be88ffb5514acf984cb.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://Towers/Assets/burn-component.png"
+dest_files=["res://.godot/imported/burn-component.png-c625b666f5c33be88ffb5514acf984cb.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/Towers/Assets/burn-component.png~ b/Towers/Assets/burn-component.png~
new file mode 100644
index 0000000..c9c1619
--- /dev/null
+++ b/Towers/Assets/burn-component.png~
Binary files differ
diff --git a/Towers/Assets/frost-component.png b/Towers/Assets/frost-component.png
new file mode 100644
index 0000000..e1c12f7
--- /dev/null
+++ b/Towers/Assets/frost-component.png
Binary files differ
diff --git a/Towers/Assets/frost-component.png.import b/Towers/Assets/frost-component.png.import
new file mode 100644
index 0000000..d22126b
--- /dev/null
+++ b/Towers/Assets/frost-component.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://ba3dmlce1wv2p"
+path="res://.godot/imported/frost-component.png-e1bd3aee287cb92be940679bf3553e5f.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://Towers/Assets/frost-component.png"
+dest_files=["res://.godot/imported/frost-component.png-e1bd3aee287cb92be940679bf3553e5f.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/Towers/Assets/range-component.png b/Towers/Assets/range-component.png
new file mode 100644
index 0000000..e5ef51e
--- /dev/null
+++ b/Towers/Assets/range-component.png
Binary files differ
diff --git a/Towers/Assets/range-component.png.import b/Towers/Assets/range-component.png.import
new file mode 100644
index 0000000..c626726
--- /dev/null
+++ b/Towers/Assets/range-component.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://dx07y4scyi5a1"
+path="res://.godot/imported/range-component.png-5b23d157d3796cb80d7b2edb7addabe5.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://Towers/Assets/range-component.png"
+dest_files=["res://.godot/imported/range-component.png-5b23d157d3796cb80d7b2edb7addabe5.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/Towers/Assets/range-component.png~ b/Towers/Assets/range-component.png~
new file mode 100644
index 0000000..e1c12f7
--- /dev/null
+++ b/Towers/Assets/range-component.png~
Binary files differ
diff --git a/Towers/Tower.gd b/Towers/Tower.gd
index f3b6667..54687fd 100644
--- a/Towers/Tower.gd
+++ b/Towers/Tower.gd
@@ -27,14 +27,11 @@ var is_hovered = false :
var mobs_in_range: Array = []
-var selection_area: Area2D
+#var selection_area: Area2D
# rpc owner id
var owner_id = 1
-# unique shared id on the network on all clients
-var network_id
-
@export var attack_range: int = 32
@export var attack_power: int = 1
@export var attack_speed: int = 1
@@ -74,12 +71,12 @@ func _process(_delta: float) -> void:
shoot()
$ShootCooldown.start()
- if selection_area and is_instance_valid(selection_area):
- var bodies = selection_area.get_overlapping_bodies()
- if bodies.size() > 0:
- selection_area.queue_free()
- for body in bodies:
- Client.select_tower(body)
+ #if selection_area and is_instance_valid(selection_area):
+ #var bodies = selection_area.get_overlapping_bodies()
+ #if bodies.size() > 0:
+ #selection_area.queue_free()
+ #for body in bodies:
+ #Client.select_tower(body)
func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
@@ -87,25 +84,7 @@ func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
if owner_id != multiplayer.get_unique_id():
return
- if Client.state is StateDefault:
- if event.is_action_pressed("builder_tower_select"):
- Client.select_tower(self)
-
- if event is InputEventMouseButton:
- if event.is_double_click():
- selection_area = Area2D.new()
- selection_area.position = (
- Client.stage.get_node("Camera").get_rect().position +
- Client.stage.get_node("Camera").get_rect().size / 2
- )
- selection_area.set_collision_mask_value(3, true)
- var collision_shape = CollisionShape2D.new()
- var shape = RectangleShape2D.new()
- shape.size = Client.stage.get_node("Camera").get_rect().size
- collision_shape.shape = shape
- selection_area.add_child(collision_shape)
- get_tree().current_scene.add_child(selection_area)
-
+ if Client.state is StateBuild:
if event.is_action_pressed("builder_cancel"):
Client.remove_tower(self)
@@ -114,22 +93,45 @@ func _on_range_body_entered(body: Node2D) -> void:
mobs_in_range.append(body)
func _on_range_body_exited(body: Node2D) -> void:
- mobs_in_range.remove_at(mobs_in_range.find(body))
+ mobs_in_range.erase(body)
-func _on_mouse_entered() -> void:
+func _on_selectable_area_hover_enter() -> void:
is_hovered = true
-func _on_mouse_exited() -> void:
+func _on_selectable_area_hover_exit() -> void:
is_hovered = false
+func _on_selectable_area_select(event: InputEvent) -> void:
+ # disable remote select for now
+ if owner_id != multiplayer.get_unique_id():
+ 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)
+
+
+
func is_melee_range():
return attack_range <= (Client.stage.map.tile_set.tile_size.x * 2)
func shoot():
- var target = mobs_in_range.pick_random() as Unit
+ if get_multiplayer_authority() != multiplayer.get_unique_id():
+ # TODO: do shoot animation, but don't subtract hp
+ return
+
+ var target = mobs_in_range[0] as Unit
if is_melee_range():
target.set_hp(target.hp - 1)
@@ -158,7 +160,7 @@ func _on_tree_exiting() -> void:
func get_rpc_properties() -> Dictionary:
return {
+ "name": null,
"global_position": null,
"owner_id": null,
- "network_id": null,
}
diff --git a/Towers/Tower.tscn b/Towers/Tower.tscn
index dfb2364..4177a3a 100644
--- a/Towers/Tower.tscn
+++ b/Towers/Tower.tscn
@@ -1,13 +1,17 @@
-[gd_scene load_steps=5 format=3 uid="uid://by1x56w21o165"]
+[gd_scene load_steps=7 format=3 uid="uid://by1x56w21o165"]
[ext_resource type="Script" path="res://Towers/Tower.gd" id="1_axo1d"]
[ext_resource type="Texture2D" uid="uid://b1b18rd0tqbar" path="res://core_outdoor.png" id="1_mrep8"]
+[ext_resource type="PackedScene" uid="uid://cqktpc8c7ecn3" path="res://Game/Selection/SelectableArea.tscn" id="3_57d5u"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_atm5x"]
size = Vector2(31, 31)
[sub_resource type="CircleShape2D" id="CircleShape2D_qa8kt"]
+[sub_resource type="RectangleShape2D" id="RectangleShape2D_312i7"]
+size = Vector2(32, 32)
+
[node name="Tower" type="StaticBody2D"]
y_sort_enabled = true
collision_layer = 4
@@ -38,9 +42,18 @@ shape = SubResource("CircleShape2D_qa8kt")
[node name="ShootCooldown" type="Timer" parent="."]
one_shot = true
+[node name="SelectableArea" parent="." instance=ExtResource("3_57d5u")]
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="SelectableArea"]
+position = Vector2(16, 16)
+shape = SubResource("RectangleShape2D_312i7")
+
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="tree_exiting" from="." to="." method="_on_tree_exiting"]
[connection signal="body_entered" from="Range" to="." method="_on_range_body_entered"]
[connection signal="body_exited" from="Range" to="." method="_on_range_body_exited"]
+[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"]