public void handleGameInfo(NetworkMessage msg)
        {
            byte[]   bytes   = msg.reader.ReadBytesAndSize();
            GameInfo infoMsg = Game.ClientController.Deserialize <GameInfo> (bytes);;

            if (infoMsg.gameOver)
            {
                string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver;
                TCPLocalConnection.sendMessage(gameOverString);
                isGameOver = true;
                UnetRoomConnector.shutdownCurrentConnection();

                string gameOverMsg;
                if (infoMsg.winnerColor == Game.PlayerColor.None)
                {
                    gameOverMsg = "It's a draw!";
                }
                else
                {
                    gameOverMsg = infoMsg.winnerColor + " won";
                }

                CurrentGame.gameOver(gameOverMsg);
            }
        }
        public void handleGameInfoMsg(NetworkMessage initMsg)
        {
            GameInfo msg = Deserialize <GameInfo> (initMsg.reader.ReadBytesAndSize());

            if (msg.gameOver)
            {
                isGameOver        = true;
                canSendServerMsg  = false;
                isListeningForTCP = false;


                UnetRoomConnector.shutdownCurrentConnection();

                string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver;
                string gameOverMsg;
                //Debug.LogError ("Winner: " + msg.winnerColor);
                if (msg.winnerColor == Game.PlayerColor.None)
                {
                    gameOverMsg = "It's a draw!";
                    TCPLocalConnection.sendMessage(gameOverString + ": 0");
                }
                else
                {
                    gameOverMsg = msg.winnerColor + " won";
                    TCPLocalConnection.sendMessage(gameOverString + ": " + (msg.winnerColor == PlayerColor.Blue ? "1" : "-1"));
                }
                CurrentGame.gameOver(gameOverMsg);
            }
        }
示例#3
0
 public void gameOver()
 {
     isGameOver       = true;
     canSendServerMsg = false;
     UnetRoomConnector.shutdownCurrentConnection();
     localGameUI.stopAllTimers();
     ClientPlayersHandler.killBots();
 }
示例#4
0
    protected override void Awake()
    {
        if (ClientUIOverlord.hasLoaded)
        {
            Destroy(this.gameObject);
        }

        base.Awake();
        singleton       = this;
        Logger.LogLevel = LogLevel;
        NetworkManager  = NetworkManager ?? FindObjectOfType <NetworkManager>();
    }
示例#5
0
    protected virtual void Start()
    {
        if (ClientUIOverlord.hasLoaded)
        {
            return;
        }
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        if (transform.parent == null)
        {
            DontDestroyOnLoad(this.gameObject);
        }
        else
        {
            DontDestroyOnLoad(transform.parent.gameObject);
        }

        instance = this;
        SceneManager.sceneLoaded += newLevelLoaded;
        // If we currently have a room access
        // (it might have been set in a previous scene)
        if (RoomAccess != null)
        {
            if (SceneManager.GetActiveScene().name == RoomAccess.SceneName) // If we're atthe correct scene
            {
                ConnectToGame(RoomAccess);
            }
            else if (SwitchScenesIfWrongScene) // Switch to correct scene
            {
                ClientUIStateManager.requestGotoState(ClientUIStates.PlayingGame, RoomAccess.SceneName);
            }
        }
    }
示例#6
0
 public static void restartCurrentGame()
 {
     UnetRoomConnector.shutdownCurrentConnection();
     Msf.Connection.SendMessage((short)ServerCommProtocl.RestartTrainingGame, gameSpecs.roomID, Msf.Helper.handleErrorResponse);
 }