summaryrefslogtreecommitdiff
path: root/Game/Client.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Client.gd')
-rw-r--r--Game/Client.gd31
1 files changed, 10 insertions, 21 deletions
diff --git a/Game/Client.gd b/Game/Client.gd
index 5051dc6..db33a26 100644
--- a/Game/Client.gd
+++ b/Game/Client.gd
@@ -8,7 +8,7 @@ var state: State :
state = value
stage_state_changed.emit(value)
-var stage: Stage
+var current_stage: Stage
var player: Player:
get():
@@ -19,34 +19,25 @@ func _ready():
pass
-func initialize_stage(current_stage: Stage):
- stage = current_stage
+func initialize_stage(stage: Stage):
+ current_stage = stage
-func place_tower(tower: Tower, position: Vector2):
+func place_tower(tower: Tower):
var network_id = multiplayer.get_unique_id()
tower.owner_id = network_id
- #tower.set_multiplayer_authority(network_id)
tower.name = "Tower@" + str(network_id) + "@" + str(Time.get_ticks_usec())
- stage.place_tower(tower, position)
- Network.place_tower.rpc(inst_to_dict(tower.to_network_data()))
- #Network.place_tower.rpc(Network.to_rpc_object(tower), position)
-
- player.towers[position] = tower
- player.score += 1
- Network.update_player.rpc({"score": player.score})
+ current_stage.place_tower.rpc(inst_to_dict(tower.to_network_data()))
func remove_tower(tower: Tower):
if tower.owner_id == multiplayer.get_unique_id():
destroy_tower(tower)
- player.score -= 1
- Network.update_player.rpc({"score": player.score})
func destroy_tower(tower: Tower):
- stage.destroy_tower(tower)
+ current_stage.destroy_tower(tower)
Network.destroy_tower.rpc(tower.global_position)
player.towers.erase(tower.global_position)
@@ -67,10 +58,9 @@ func update_tower(path: NodePath, data: Tower.NetworkData):
Network.update_tower.rpc(path, inst_to_dict(data))
-func spawn_unit(unit: Unit, spawn: Spawn):
+func spawn_unit(unit: Unit, spawn: Spawn, overwrite_target: PathNode = null):
var network_id = multiplayer.get_unique_id()
unit.owner_id = network_id
- #unit.set_multiplayer_authority(network_id)
unit.name = "Unit@" + str(network_id) + "@" + str(Time.get_ticks_usec())
unit.global_position = spawn.spawn_position
@@ -78,12 +68,11 @@ func spawn_unit(unit: Unit, spawn: Spawn):
unit.hp = randi_range(50, 150) #20000b
unit.speed = randi_range(100, 150)
- stage.spawn_unit(unit)
+ if overwrite_target:
+ unit.target = overwrite_target
#var data := UnitCreationData.fromUnit(unit)
- var data := unit.to_network_data()
- Network.spawn_unit.rpc(inst_to_dict(data))
- #Network.spawn_unit.rpc(Network.to_rpc_object(unit), Network.to_rpc_object(spawn))
+ current_stage.spawn_unit.rpc(inst_to_dict(unit.to_network_data()))
func array_intersect(first, second):