summaryrefslogtreecommitdiff
path: root/Towers
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-05 11:34:49 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-05 11:34:49 +0100
commitc8f674ac6fa0914d9e448d2929f2385cdad80d60 (patch)
treea913454c42bb520aa644f4e2dcf0d42ba11c83de /Towers
parent84365b6f901a9c0251a9f724a8d9f81a3787e97d (diff)
next commit
Diffstat (limited to 'Towers')
-rw-r--r--Towers/Assets/.spritesheet.png-autosave.krabin79919 -> 0 bytes
-rw-r--r--Towers/Assets/shoot.oggbin0 -> 6381 bytes
-rw-r--r--Towers/Assets/shoot.ogg.import19
-rw-r--r--Towers/Components/TowerComponent.gd2
-rw-r--r--Towers/PlacementParticles.tscn2
-rw-r--r--Towers/Tower.gd22
-rw-r--r--Towers/Tower.tscn6
7 files changed, 41 insertions, 10 deletions
diff --git a/Towers/Assets/.spritesheet.png-autosave.kra b/Towers/Assets/.spritesheet.png-autosave.kra
deleted file mode 100644
index 0f3888a..0000000
--- a/Towers/Assets/.spritesheet.png-autosave.kra
+++ /dev/null
Binary files differ
diff --git a/Towers/Assets/shoot.ogg b/Towers/Assets/shoot.ogg
new file mode 100644
index 0000000..492e86c
--- /dev/null
+++ b/Towers/Assets/shoot.ogg
Binary files differ
diff --git a/Towers/Assets/shoot.ogg.import b/Towers/Assets/shoot.ogg.import
new file mode 100644
index 0000000..d094c68
--- /dev/null
+++ b/Towers/Assets/shoot.ogg.import
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://cpkwvp5llf7x6"
+path="res://.godot/imported/shoot.ogg-8774a88813cc4a3e47919b1c05404869.oggvorbisstr"
+
+[deps]
+
+source_file="res://Towers/Assets/shoot.ogg"
+dest_files=["res://.godot/imported/shoot.ogg-8774a88813cc4a3e47919b1c05404869.oggvorbisstr"]
+
+[params]
+
+loop=false
+loop_offset=0
+bpm=0
+beat_count=0
+bar_beats=4
diff --git a/Towers/Components/TowerComponent.gd b/Towers/Components/TowerComponent.gd
index 83fdc38..609f88c 100644
--- a/Towers/Components/TowerComponent.gd
+++ b/Towers/Components/TowerComponent.gd
@@ -29,7 +29,7 @@ func to_network_data() -> NetworkData:
return data
-func update_with_network_data(data: NetworkData):
+func update_with_network_data(_data: NetworkData):
pass
static func from_network_data(data: NetworkData) -> TowerComponent:
diff --git a/Towers/PlacementParticles.tscn b/Towers/PlacementParticles.tscn
index d70768d..845e451 100644
--- a/Towers/PlacementParticles.tscn
+++ b/Towers/PlacementParticles.tscn
@@ -84,4 +84,4 @@ flip_h = true
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_0cdk8")
-volume_db = -16.0
+volume_db = -4.0
diff --git a/Towers/Tower.gd b/Towers/Tower.gd
index 2634966..187cd93 100644
--- a/Towers/Tower.gd
+++ b/Towers/Tower.gd
@@ -58,6 +58,7 @@ signal selection_group_id_changed(previous_id: String)
set(value):
attack_range = value
$Range/CollisionShape2D.shape.radius = attack_range
+ $SoundShoot.max_distance = attack_range * Client.current_stage.map.tile_set.tile_size.x
@export var attack_power: int = 1
@@ -112,9 +113,10 @@ func _draw():
func _process(_delta: float) -> void:
- if $ShootCooldown.is_stopped() and not mobs_in_range.is_empty():
- shoot()
- $ShootCooldown.start()
+ if multiplayer.is_server():
+ if $ShootCooldown.is_stopped() and not mobs_in_range.is_empty():
+ shoot()
+ $ShootCooldown.start()
#if selection_area and is_instance_valid(selection_area):
#var bodies = selection_area.get_overlapping_bodies()
@@ -193,21 +195,24 @@ func is_melee_range():
func shoot():
- if not multiplayer.is_server():
- # TODO: do shoot animation, but don't subtract hp
- return
-
var target = mobs_in_range[0] as Unit
for component in components:
if component.has_method("on_shoot"):
component.on_shoot(target)
+ shoot_fx.rpc()
+
if is_melee_range():
target.set_hp(target.hp - 1)
else: # TODO
target.set_hp(target.hp - 1)
+@rpc("authority", "call_local")
+func shoot_fx():
+ $SoundShoot.play()
+
+
func get_region():
var collision_shape := $CollisionShape2D
@@ -293,4 +298,7 @@ static func from_network_data(data: NetworkData) -> Tower:
tower.attack_power = data.attack_power
tower.attack_speed = data.attack_speed
+ tower.get_node("AnimatedSprite2D").modulate = data.sprite_modulate
+ tower.get_node("ComponentsAnchor").modulate = data.components_anchor_modulate
+
return tower
diff --git a/Towers/Tower.tscn b/Towers/Tower.tscn
index 13bbe72..25388f6 100644
--- a/Towers/Tower.tscn
+++ b/Towers/Tower.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=15 format=3 uid="uid://by1x56w21o165"]
+[gd_scene load_steps=16 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"]
[ext_resource type="Texture2D" uid="uid://dujcs2ls3u6tj" path="res://Towers/Assets/spritesheet.png" id="3_brkps"]
+[ext_resource type="AudioStream" uid="uid://cpkwvp5llf7x6" path="res://Towers/Assets/shoot.ogg" id="5_i05ow"]
[sub_resource type="AtlasTexture" id="AtlasTexture_1ubf7"]
atlas = ExtResource("3_brkps")
@@ -114,6 +115,9 @@ position = Vector2(0, 32)
[node name="GroundAnchor" type="Marker2D" parent="."]
position = Vector2(16, 29)
+[node name="SoundShoot" type="AudioStreamPlayer2D" parent="."]
+stream = ExtResource("5_i05ow")
+
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="tree_exiting" from="." to="." method="_on_tree_exiting"]
[connection signal="body_entered" from="Range" to="." method="_on_range_body_entered"]