summaryrefslogtreecommitdiff
path: root/Towers/Tower.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Towers/Tower.gd')
-rw-r--r--Towers/Tower.gd22
1 files changed, 15 insertions, 7 deletions
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