Exemple #1
0
        // Event Handlers

        void OnConnect(NetworkConnection connection)
        {
            var client = new NetworkClientPlayer(connection, LowestAvailablePlayerID(connection));

            client.Config.PlayerID = client.PlayerID;
            clients[connection]    = client;
            PlayerAdded?.Invoke(client);
        }
Exemple #2
0
        public INetworkClient CreateLocalClient()
        {
            // TODO(james7132): Make this dynamic
            var clientToServer  = new LocalInterface();
            var serverInterface = clientToServer.Mirror;
            var serverToClient  = serverInterface.Connection;
            var localClient     = new NetworkClientPlayer(serverToClient, LowestAvailablePlayerID(serverToClient));

            localClient.Config.PlayerID = localClient.PlayerID;
            clients[serverToClient]     = localClient;
            PlayerAdded?.Invoke(localClient);
            AddNetworkInterface(serverInterface);
            return(new NetworkGameClient(clientToServer.Connection));
        }
Exemple #3
0
 void ServerHandleClientReady(NetworkClientPlayer player)
 {
     if (!player.IsReady)
     {
         return;
     }
     Debug.Log($"Server: Client {player.PlayerID} is Ready");
     if (!AllClientsAreReady)
     {
         return;
     }
     Debug.Log("Server: All Clients are Ready");
     NetworkManager.Server.SetReady(true);
     ServerReady.TrySetResult(true);
 }
Exemple #4
0
 void InitalizePlayer(NetworkClientPlayer player)
 {
     player.Config.Selection = CharacterSelectMenu.CreateNewSelection(player.PlayerID);
 }
Exemple #5
0
 void OnServerUpdatePlayer(NetworkClientPlayer player) => OnServerUpdatedConfig();
Exemple #6
0
 void OnServerAddPlayer(NetworkClientPlayer player)
 {
     InitalizePlayer(player);
     OnServerUpdatedConfig();
 }
Exemple #7
0
 internal void InvokePlayerUpdated(NetworkClientPlayer client)
 {
     PlayerUpdated?.Invoke(client);
 }
 void OnServerUpdatePlayer(NetworkClientPlayer player)
 {
     Debug.Log($"Player config updated: {player.PlayerID} {player.Config}");
     OnServerUpdatedConfig();
 }