Some fixed to networking demo

This commit is contained in:
Juan Linietsky
2016-08-19 18:42:14 -03:00
parent d9c91b93d9
commit 4edf90374f
3 changed files with 8 additions and 5 deletions

View File

@@ -12,7 +12,6 @@ func explode():
if (not is_network_master()):
#but will call explosion only on master
return
for p in in_area:
if (p.has_method("exploded")):
p.rpc("exploded",owner) #exploded has a master keyword, so it will only be received by the master

View File

@@ -72,7 +72,7 @@ remote func unregister_player(id):
emit_signal("player_list_changed")
remote func pre_start_game(spawn_points):
#change scene
#change scene
var world = load("res://world.tscn").instance()
get_tree().get_root().add_child(world)
@@ -105,7 +105,9 @@ remote func pre_start_game(spawn_points):
world.get_node("score").add_player(pn,players[pn])
if (not get_tree().is_network_server()):
rpc("ready_to_start", get_tree().get_network_unique_id() )
#tell server we are ready to start
rpc_id(1,"ready_to_start", get_tree().get_network_unique_id() )
elif players.size()==0:
post_start_game()
@@ -124,7 +126,7 @@ remote func ready_to_start(id):
if (players_ready.size() == players.size()):
for p in players:
rpc( "post_start_game" )
rpc_id(p, "post_start_game" )
post_start_game()
@@ -158,7 +160,7 @@ func begin_game():
spawn_point_idx+=1
#call to pre-start game with the spawn points
for p in players:
rpc( "pre_start_game", spawn_points )
rpc_id(p, "pre_start_game", spawn_points )
pre_start_game( spawn_points )

View File

@@ -14,6 +14,8 @@ sync func setup_bomb(name,pos,by_who):
bomb.set_name( name ) #ensure unique name for the bomb
bomb.set_pos( pos )
bomb.owner=by_who
#no need to set network mode to bomb, will be owned by master by
#default
get_node("../..").add_child(bomb)
var current_anim=""