Example #1
0
 public GameState(Game game, GameStateManager manager)
     : base(game)
 {
     this.stateManager = manager;
     this.childComponents = new List<GameComponent>();
     this.tag = this;
 }
Example #2
0
        /// <summary> Used to move to another state and keep the previous state in stack </summary>
        public void PushState(GameState newState)
        {
            this.drawOrder += DrawOrderInc;
            newState.DrawOrder = this.drawOrder;

            this.AddState(newState);

            if (this.onStateChange != null)
            {
                this.onStateChange(this, null);
            }
        }
Example #3
0
        /// <summary> Removes all other states from stack except the specified one. </summary>
        public void ChangeState(GameState newState)
        {
            while (this.gameStates.Count > 0)
            {
                this.RemoveState();
            }

            newState.DrawOrder = StartDrawOrder;
            this.drawOrder = StartDrawOrder;

            this.AddState(newState);

            if (this.onStateChange != null)
            {
                this.onStateChange(this, null);
            }
        }
Example #4
0
 /// <summary> Adds a state to the stack and subscribes it to the event. </summary>
 private void AddState(GameState newState)
 {
     this.gameStates.Push(newState);
     Game.Components.Add(newState);
     this.onStateChange += newState.StateChange;
 }
Example #5
0
 /// <summary> Adds a state to the stack and subscribes it to the event. </summary>
 private void AddState(GameState newState)
 {
     this.gameStates.Push(newState);
     Game.Components.Add(newState);
     this.onStateChange += newState.StateChange;
 }