Exemplo n.º 1
0
    private IEnumerator checkPlayerCount(NetworkConnection conn)
    {
        yield return(new WaitForSeconds(2f));

        print("LocalPlayersCount: " + ClientScene.localPlayers.Count);
        print("ReadyConnection count: " + ClientScene.readyConnection.playerControllers.Count);

        // There is a bug when after a game match finishes  and a client reconnects to the server, the client is not given a player
        // In such a situation, we can force the server to reload the scene and try to provide all clients a player.

        if (ClientScene.localPlayers.Count > 0 && ClientScene.readyConnection.playerControllers.Count == 0)
        {
            Debug.LogError("Unknown Error. Player won't spawn");
            ReloadSceneMessage reloadMessage = new ReloadSceneMessage();
            ClientScene.readyConnection.Send(9002, reloadMessage);
        }
    }
    private IEnumerator checkPlayerCount(NetworkConnection conn)
    {
        yield return new WaitForSeconds(2f);

        print ("LocalPlayersCount: " + ClientScene.localPlayers.Count);
        print("ReadyConnection count: " + ClientScene.readyConnection.playerControllers.Count);

        // There is a bug when after a game match finishes  and a client reconnects to the server, the client is not given a player
        // In such a situation, we can force the server to reload the scene and try to provide all clients a player.

        if(ClientScene.localPlayers.Count > 0 && ClientScene.readyConnection.playerControllers.Count == 0)
        {
            Debug.LogError ("Unknown Error. Player won't spawn");
            ReloadSceneMessage reloadMessage = new ReloadSceneMessage();
            ClientScene.readyConnection.Send (9002, reloadMessage);
        }
    }