Esempio n. 1
0
        public void SendNotReadyToBeginMessage()
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyPlayer SendReadyToBeginMessage");
            }

            var lobby = NetworkManager.singleton as NetworkLobbyManager;

            if (lobby)
            {
                var msg = new LobbyReadyToBeginMessage();
                msg.slotId     = (byte)playerControllerId;
                msg.readyState = false;
                lobby.client.Send(MsgType.LobbyReadyToBegin, msg);
            }
        }
        void OnServerReadyToBeginMessage(NetworkMessage netMsg)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage");
            }
            netMsg.ReadMessage(s_ReadyToBeginMessage);

            PlayerController lobbyController;

            if (!Utils.GetPlayerController((short)s_ReadyToBeginMessage.slotId, netMsg.conn, out lobbyController))
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkLobbyManager OnServerReadyToBeginMessage invalid playerControllerId " + s_ReadyToBeginMessage.slotId);
                }
                return;
            }

            // set this player ready
            var lobbyPlayer = lobbyController.gameObject.GetComponent <NetworkLobbyPlayer>();

            lobbyPlayer.readyToBegin = s_ReadyToBeginMessage.readyState;

            // tell every player that this player is ready
            var outMsg = new LobbyReadyToBeginMessage();

            outMsg.slotId     = lobbyPlayer.slot;
            outMsg.readyState = s_ReadyToBeginMessage.readyState;
            NetworkServer.SendToReady(null, MsgType.LobbyReadyToBegin, outMsg);

            OnLobbyServerReadyToBegin(netMsg.conn);

            // maybe start the game
            CheckReadyToBegin();
        }