Beispiel #1
0
        void OnServerReadyToBeginMessage(NetworkMessage netMsg)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage");
            }
            netMsg.ReadMessage(s_ReadyToBeginMessage);

            PlayerController lobbyController;

            if (!netMsg.conn.GetPlayerController((short)s_ReadyToBeginMessage.slotId, 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);

            // maybe start the game
            CheckReadyToBegin();
        }
Beispiel #2
0
        private void OnServerReadyToBeginMessage(NetworkMessage netMsg)
        {
            PlayerController controller;

            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage");
            }
            netMsg.ReadMessage <LobbyReadyToBeginMessage>(s_ReadyToBeginMessage);
            if (!netMsg.conn.GetPlayerController(s_ReadyToBeginMessage.slotId, out controller))
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkLobbyManager OnServerReadyToBeginMessage invalid playerControllerId " + s_ReadyToBeginMessage.slotId);
                }
            }
            else
            {
                NetworkLobbyPlayer component = controller.gameObject.GetComponent <NetworkLobbyPlayer>();
                component.readyToBegin = s_ReadyToBeginMessage.readyState;
                LobbyReadyToBeginMessage msg = new LobbyReadyToBeginMessage {
                    slotId     = component.slot,
                    readyState = s_ReadyToBeginMessage.readyState
                };
                NetworkServer.SendToReady(null, 0x2b, msg);
                this.CheckReadyToBegin();
            }
        }
Beispiel #3
0
        private void OnServerReadyToBeginMessage(NetworkMessage netMsg)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage");
            }
            netMsg.ReadMessage(s_ReadyToBeginMessage);
            if (!netMsg.conn.GetPlayerController(s_ReadyToBeginMessage.slotId, out PlayerController playerController))
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkLobbyManager OnServerReadyToBeginMessage invalid playerControllerId " + s_ReadyToBeginMessage.slotId);
                }
                return;
            }
            NetworkLobbyPlayer component = playerController.gameObject.GetComponent <NetworkLobbyPlayer>();

            component.readyToBegin = s_ReadyToBeginMessage.readyState;
            LobbyReadyToBeginMessage lobbyReadyToBeginMessage = new LobbyReadyToBeginMessage();

            lobbyReadyToBeginMessage.slotId     = component.slot;
            lobbyReadyToBeginMessage.readyState = s_ReadyToBeginMessage.readyState;
            NetworkServer.SendToReady(null, 43, lobbyReadyToBeginMessage);
            CheckReadyToBegin();
        }
    void OnServerReadyToBeginMessage(NetworkMessage netMsg)
    {
        if (LogFilter.logDebug)
        {
            Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage");
        }
        netMsg.ReadMessage(s_ReadyToBeginMessage);

        UnityEngine.Networking.PlayerController lobbyController = netMsg.conn.playerControllers.First();

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

        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);

        // maybe start the game
        CheckReadyToBegin();
    }
 // sent from a client to tell the server it's ready
 public void SetReady()
 {
     // notify server that we're ready
     foreach (var p in lobbySlots)
     {
         if (p != null && p.playerControllerId >= 0)
         {
             var msg = new LobbyReadyToBeginMessage();
             msg.slotId     = (byte)p.playerControllerId;
             msg.readyState = true;
             client.Send(UnityEngine.Networking.MsgType.LobbyReadyToBegin, msg);
         }
     }
 }
    // sent from server to set all its clients to not ready and tell all clients they are not ready
    public void SetAllClientsNotReady()
    {
        foreach (var player in lobbySlots)
        {
            if (player != null)
            {
                player.GetComponent <NetworkCompat.NetworkLobbyPlayer>().readyToBegin = false;

                LobbyReadyToBeginMessage msg = new LobbyReadyToBeginMessage();
                msg.slotId     = player.slot;
                msg.readyState = false;
                UnityEngine.Networking.NetworkServer.SendToReady(null, MsgType.LobbyReadyToBegin, msg);
            }
        }
    }
Beispiel #7
0
        public void SendNotReadyToBeginMessage()
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyPlayer SendReadyToBeginMessage");
            }
            NetworkLobbyManager networkLobbyManager = NetworkManager.singleton as NetworkLobbyManager;

            if ((bool)networkLobbyManager)
            {
                LobbyReadyToBeginMessage lobbyReadyToBeginMessage = new LobbyReadyToBeginMessage();
                lobbyReadyToBeginMessage.slotId     = (byte)base.playerControllerId;
                lobbyReadyToBeginMessage.readyState = false;
                networkLobbyManager.client.Send(43, lobbyReadyToBeginMessage);
            }
        }
Beispiel #8
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);
            }
        }
        public void SendReadyToBeginMessage()
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobbyPlayer SendReadyToBeginMessage");
            }
            NetworkLobbyManager singleton = NetworkManager.singleton as NetworkLobbyManager;

            if (singleton != null)
            {
                LobbyReadyToBeginMessage msg = new LobbyReadyToBeginMessage {
                    slotId     = (byte)base.playerControllerId,
                    readyState = true
                };
                singleton.client.Send(0x2b, msg);
            }
        }
    IEnumerator FadeOutToLeaderboardScene()
    {
        float fadeTime = GameObject.Find("Fade").GetComponent <FadeScene> ().BeginFadeOut();

        yield return(new WaitForSeconds(fadeTime));

        _networkLobbyManager.ServerChangeScene("Leaderboard");
        _currentScene = "Leaderboard";         // put this in some scene load callback
        foreach (var lobbyPlayer in _networkLobbyManager.lobbySlots)
        {
            if (lobbyPlayer == null)
            {
                continue;
            }

            lobbyPlayer.GetComponent <NetworkCompat.NetworkLobbyPlayer> ().readyToBegin = true;

            // tell every player that this player is ready
            var outMsg = new LobbyReadyToBeginMessage();
            outMsg.slotId     = lobbyPlayer.slot;
            outMsg.readyState = true;
            UnityEngine.Networking.NetworkServer.SendToReady(null, UnityEngine.Networking.MsgType.LobbyReadyToBegin, outMsg);
        }
    }
Beispiel #11
0
    public void SendReadyToBeginMessage()
    {
        if (LogFilter.logDebug) { Debug.Log("NetworkLobbyPlayer SendReadyToBeginMessage"); }

        var lobby = NetworkManager.singleton as LobbyManager;
        if (lobby)
        {
            var msg = new LobbyReadyToBeginMessage();
            msg.slotId = (byte)playerControllerId;
            msg.readyState = true;
            lobby.client.Send(MsgType.LobbyReadyToBegin, msg);
        }
    }
Beispiel #12
0
    void OnServerReadyToBeginMessage(NetworkMessage netMsg)
    {
        if (LogFilter.logDebug) { Debug.Log("NetworkLobbyManager OnServerReadyToBeginMessage"); }
        netMsg.ReadMessage(s_ReadyToBeginMessage);

        PlayerController lobbyController = netMsg.conn.playerControllers.First();

        // set this player ready
        var lobbyPlayer = lobbyController.gameObject.GetComponent<LobbyPlayer>();
        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);

        // maybe start the game
        CheckReadyToBegin();
    }