Exemple #1
0
 private void TellClientsToUpdateUI()
 {
     InvokeClientRpcOnEveryone(SetDropdownValueOnClient, canvas.levelDropdown.value, canvas.winConDropdown.value);
     canvas.updatePlayerBarsOnServer(readyPlayers);
     InvokeClientRpcOnEveryone(UpdateConnectedOnClient, connected);
     InvokeClientRpcOnEveryone(UpdatePlayerNamesOnClient, canvas.playerBars.getLeftPlayerName(), canvas.playerBars.getRightPlayerName());
     InvokeClientRpcOnEveryone(UpdatePlayerScoresOnClient, canvas.playerBars.getLeftPlayerScore(), canvas.playerBars.getRightPlayerScore());
     InvokeClientRpcOnEveryone(UpdatePlayerReadyOnClient, canvas.playerBars.getLeftPlayerReady(), canvas.playerBars.getRightPlayerReady());
 }
Exemple #2
0
    public override void NetworkStart()
    {
        // init vars
        readyPlayers = new List <ulong>();

        // Find the canvas.
        canvas = FindObjectOfType <LobbyCanvas>();
        canvas.initialize();

        // UI
        canvas.updatePlayerBarsOnServer(readyPlayers);
        canvas.initHostPanel(IsHost);

        // Destroy main menu music
        GameObject music = GameObject.FindGameObjectWithTag("MenuMusic");

        if (music != null)
        {
            Destroy(music);
        }

        if (IsServer)
        {
            // Call callbacks to track connections
            NetworkingManager.Singleton.OnClientConnectedCallback  += ConnectionCallbackOnServer;
            NetworkingManager.Singleton.OnClientDisconnectCallback += ConnectionCallbackOnServer;

            // Create persistent GameInfo object to pass to GameManager
            gameInfo = new GameObject("GameInfo").AddComponent <GameInfo>();
            DontDestroyOnLoad(gameInfo.gameObject);

            connected = NetworkingManager.Singleton.ConnectedClientsList.Count;
            TellClientsToUpdateUI();
        }

        if (IsClient)
        {
            // Timeout after 5 minutes in lobby
            Invoke("OnDisconnectButton", 300);
        }
    }