示例#1
0
 /// <summary>
 /// Creates a new game state
 /// </summary>
 /// <param name="game">Main XNA game</param>
 /// <param name="manager">The manager in charge of this state</param>
 public GameState(Game game, GameStateManager manager)
     : base(game)
 {
     StateManager = manager;
     childComponents = new List<GameComponent>();
     tag = this;
 }
示例#2
0
        /// <summary>
        ///  Changes the state and activates the state
        /// </summary>
        /// <param name="newState"></param>
        public void ChangeState(GameState newState)
        {
            while (gameStates.Count > 0)
                RemoveState();

            newState.DrawOrder = startDrawOrder;
            drawOrder = startDrawOrder;

            AddState(newState);

            if (OnStateChanged != null)
                OnStateChanged(this, null);
        }
示例#3
0
        /// <summary>
        /// Adds a new state without changing the active state
        /// </summary>
        /// <param name="newState"></param>
        private void AddState(GameState newState)
        {
            gameStates.Push(newState);

            Game.Components.Add(newState);

            OnStateChanged += newState.StateChange;
        }
示例#4
0
        /// <summary>
        /// Pushes a new state to the top of the stack and sets the newstate as active
        /// </summary>
        /// <param name="newState"></param>
        public void PushState(GameState newState)
        {
            drawOrder += drawOrderInc;
            newState.DrawOrder = drawOrder;

            AddState(newState);

            if (OnStateChanged != null)
                OnStateChanged(this, null);
        }
 protected void SwitchStateWithFade(GameState targetState)
 {
     this.IsExiting = true;
     StateManager.TargetState = targetState;
 }
示例#6
0
        // IMPORTANT! READ THIS BEFORE TRYING TO FIGURE OUT WHAT SwitchState DOES
        // IMPORTANT! READ THIS BEFORE TRYING TO FIGURE OUT WHAT SwitchState DOES
        // IMPORTANT! READ THIS BEFORE TRYING TO FIGURE OUT WHAT SwitchState DOES
        // IMPORTANT! READ THIS BEFORE TRYING TO FIGURE OUT WHAT SwitchState DOES
        // IMPORTANT! READ THIS BEFORE TRYING TO FIGURE OUT WHAT SwitchState DOES
        /// <summary>
        /// Kind of a hack function. Allows the fading from one state to another but you need
        /// to call FadeOutRectangle.Draw(GameRef.spriteBatch, Vector2.Zero, FadeOutColor);
        /// </summary>
        /// <param name="targetState">The state to switch to</param>
        public void SwitchState(GameState targetState)
        {
            StateManager.TargetState = targetState;

            IsExiting = true;
        }
 public LoadingState(Game game, GameStateManager manager, GameState nextState)
     : base(game, manager)
 {
     this.nextState = nextState;
 }