/// <summary> /// Constructs the gameState and passes Game and GameStateManager. /// </summary> /// <param name="game">game drawable component</param> /// <param name="manager">the stateManager</param> public GameState(Game game, GameStateManager manager) : base(game) { GameRef = (Game1)game; StateMananger = manager; stateRef = this; }
/// <summary> /// Push a state onto the stack. /// Adds it to the components list /// </summary> /// <param name="newState">GameState to be added</param> public void PushState(GameState newState) { if (gameStates.Count > 0) gameStates.Peek().HasFocus = false; gameStates.Push(newState); Game.Components.Add(newState); gameStates.Peek().HasFocus = true; }
/// <summary> /// Pushes a gameState to the stack. Calls LoadContent() /// </summary> public void PushState(GameState state) { state.LoadContent(); gameStates.Push(state); }
/// <summary> /// Pops current state and pushes the new state to the stack. /// </summary> public void ChangeState(GameState state) { PopState(); PushState(state); }
/// <summary> /// Pops the previous state and pushes a new state to the stack. /// </summary> /// <param name="newState">GameState to be added</param> public void ChangeState(GameState newState) { PopState(); PushState(newState); }