Exemple #1
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);
        }
    }