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