Beispiel #1
0
        /////// CLIENT

        // Misc

        public void ClientSetReadyCommand(bool newValue)
        {
            if (state != DNMState.Host && state != DNMState.Client)
            {
                Log.Error("Invalid call of ClientSetReady: {0}", state);
                return;
            }

            if (gameState != GameState.NoGame)
            {
                Log.Error("Invalid call of ClientSetReady: {0}", gameState);
            }

            var readyMessage = new ReadyMessage(newValue);

            client.Send(MsgType.ClientSetReady, readyMessage);
        }
Beispiel #2
0
        // Server message handlers

        void OnServerClientSetReadyMessage(NetworkMessage messageReader)
        {
            ReadyMessage msg      = messageReader.ReadMessage <ReadyMessage>();
            bool         newReady = msg.value;

            NetworkConnection conn = messageReader.conn;

            List <PlayerController> controllers = conn.playerControllers;

            foreach (PlayerController c in controllers)
            {
                OnlinePlayer dnmPlayer = c.unetView.GetComponent <OnlinePlayer>();

                if (dnmPlayer.IsReady() == newReady)
                {
                    Log.Warn("Already in this ready state");
                }
                else
                {
                    dnmPlayer.SetReady(newReady);
                }
            }
        }