示例#1
0
        public GameState Push(GameState gameState)
        {
            if (gameState == null)
            {
                throw new ArgumentNullException("gameState");
            }
            if (ActiveGameState != null)
            {
                ActiveGameState.Pause();
            }

            GameStates.Add(gameState);
            ActiveGameState = gameState;
            gameState.Start();

            return(gameState);
        }
示例#2
0
        public void Switch(GameState gameState)
        {
            if (gameState == null)
            {
                throw new ArgumentNullException("gameState");
            }

            if (ActiveGameState != null)
            {
                ActiveGameState.Pause();
            }
            if (!GameStates.Remove(gameState))
            {
                throw new ArgumentException(gameState + " is not on the stack");
            }

            GameStates.Add(gameState);

            gameState.Resume();
            ActiveGameState = gameState;
        }