예제 #1
0
 protected GameState(Game game, GameStateManager manager)
     : base(game)
 {
     StateManager = manager;
     _childComponents = new List<GameComponent>();
     _tag = this;
 }
예제 #2
0
        /// <summary>
        /// Remove all other states and set a new state
        /// </summary>
        /// <param name="newState"></param>
        public void ChangeState(GameState newState)
        {
            while (_gameStates.Count > 0)
                RemoveState();

            newState.DrawOrder = StartDrawOrder;
            _draworder = StartDrawOrder;

            AddState(newState);

            if (OnStateChange != null)
                OnStateChange(this, null);
        }
예제 #3
0
        /// <summary>
        /// Add a new state
        /// </summary>
        /// <param name="newState"></param>
        public void PushState(GameState newState)
        {
            _draworder += DrawOrderInc;
            newState.DrawOrder = _draworder;

            AddState(newState);

            if (OnStateChange != null)
                OnStateChange(this, null);
        }
예제 #4
0
        /// <summary>
        /// Helper for PushState().
        /// </summary>
        /// <param name="newState"></param>
        private void AddState(GameState newState)
        {
            _gameStates.Push(newState);

            Game.Components.Add(newState);

            // Subscribe the state to OnStateChange.
            OnStateChange += newState.StateChange;
        }