diff options
-rw-r--r-- | Global.gd | 4 | ||||
-rw-r--r-- | Network/Network.gd | 13 | ||||
-rw-r--r-- | UI/CharacterSelect.gd | 4 |
3 files changed, 14 insertions, 7 deletions
@@ -32,7 +32,9 @@ func _ready(): func init(): randomize() self.Levels.shuffle() - + self.init_level_map() + +func init_level_map(): for level in self.Levels: self.Level_Map.push_back({ time = 0, diff --git a/Network/Network.gd b/Network/Network.gd index ff076a4..1222b92 100644 --- a/Network/Network.gd +++ b/Network/Network.gd @@ -40,10 +40,10 @@ func _ready(): @rpc("any_peer") func register_player(player_name): - var id = get_tree().get_remote_sender_id() + var id = multiplayer.get_remote_sender_id() self.players[id] = { name = player_name, - ip = self.peer.get_peer_address(id), + ip = self.peer.get_peer(id).get_remote_address(), } emit_signal("player_list_changed") @@ -73,7 +73,7 @@ func leave_game(): @rpc("any_peer") func _leave_game(): - var id = get_tree().get_remote_sender_id() + var id = multiplayer.get_remote_sender_id() self.peer.disconnect_peer(id) @@ -86,15 +86,16 @@ func _on_Global_game_started(): var idx = 1 for id in self.players: self.players[id].idx = idx - rpc_id(id, "_preconfigure_game", idx) + rpc_id(id, "_preconfigure_game", idx, Global.Level_Map) idx += 1 # start game for everyone rpc("_start_game") -@rpc("any_peer") func _preconfigure_game(idx): +@rpc("any_peer") func _preconfigure_game(idx, level_map): self.player.idx = idx + Global.Level_Map = level_map @rpc("any_peer", "call_local") func _start_game(): @@ -132,7 +133,7 @@ func _connection_succeeded(): func _connection_failed(): - get_tree().set_multiplayer_peer(null) # remove peer + multiplayer.multiplayer_peer = null # remove peer emit_signal("connection_failed") diff --git a/UI/CharacterSelect.gd b/UI/CharacterSelect.gd index 348ef22..96b228c 100644 --- a/UI/CharacterSelect.gd +++ b/UI/CharacterSelect.gd @@ -49,4 +49,8 @@ func _button_pressed(event, character): func _on_start_button_pressed(): + rpc("_start_game") + + +@rpc("any_peer", "call_local") func _start_game(): get_tree().change_scene_to_file("res://UI/LevelSelect.tscn") |