|
@@ -31,9 +31,23 @@ var playerphsyics = preload('res://playersprite.tscn')
|
|
|
func _On_Connection_Succeeded():
|
|
|
$Input.enabled = true
|
|
|
print("Succesfully connected to game server")
|
|
|
- var instance = playerphsyics.instance()
|
|
|
- instance.name = str(api.get_network_unique_id())
|
|
|
- $players.add_child(instance)
|
|
|
+ if not has_node("players"): return
|
|
|
+ request_clients()
|
|
|
+ yield(self, 'client_request')
|
|
|
+ for x in current_clients:
|
|
|
+ var instance = playerphsyics.instance()
|
|
|
+ instance.name = str(x)
|
|
|
+ $players.add_child(instance)
|
|
|
+
|
|
|
+signal client_request
|
|
|
+var current_clients = []
|
|
|
+
|
|
|
+func request_clients():
|
|
|
+ rpc_id(1,'send_clients')
|
|
|
+
|
|
|
+remote func client_data(arg):
|
|
|
+ current_clients = arg
|
|
|
+ emit_signal('client_request')
|
|
|
|
|
|
# extra stuff
|
|
|
|
|
@@ -49,6 +63,7 @@ func send_input(arg):
|
|
|
rpc_id(1,'input_handler',arg)
|
|
|
|
|
|
remote func player_position(arg):
|
|
|
+ if not has_node("players"): return
|
|
|
for id in arg.keys():
|
|
|
if $players.has_node(str(id)):
|
|
|
var node = $players.get_node(str(id))
|
|
@@ -57,19 +72,23 @@ remote func player_position(arg):
|
|
|
node.global_position = arg[id]
|
|
|
|
|
|
remote func player_animation(arg):
|
|
|
+ if not has_node("players"): return
|
|
|
for id in arg.keys():
|
|
|
if $players.has_node(str(id)):
|
|
|
$players.get_node(str(id)).animation = arg[id]
|
|
|
|
|
|
remote func enemies_position(arg):
|
|
|
- if has_node('enemies'):
|
|
|
- for i in $enemies.get_children():
|
|
|
- i.hide()
|
|
|
- for id in arg.keys().size():
|
|
|
- var node = $enemies.get_child(id)
|
|
|
- node.global_position = arg[arg.keys()[id]][0]
|
|
|
- node.animation = arg[arg.keys()[id]][1]
|
|
|
- node.show()
|
|
|
-
|
|
|
-remote func attack_anim(arg):
|
|
|
- $players.get_node( str(api.get_network_unique_id()) ).get_node('weapon/AnimationPlayer').play(arg)
|
|
|
+ if not has_node('enemies'): return
|
|
|
+ for i in $enemies.get_children():
|
|
|
+ i.hide()
|
|
|
+ for id in arg.keys().size():
|
|
|
+ var node = $enemies.get_child(id)
|
|
|
+ node.global_position = arg[arg.keys()[id]][0]
|
|
|
+ node.animation = arg[arg.keys()[id]][1]
|
|
|
+ node.show()
|
|
|
+
|
|
|
+remote func attack_anim(arg, id):
|
|
|
+ if not has_node("players"): return
|
|
|
+# for i in $players.get_children():
|
|
|
+# print(i.name)
|
|
|
+ $players.get_node(str(id)).get_node('weapon/AnimationPlayer').play(arg)
|