public void PushState(GameState newState)
        {
            drawOrder += 100;
            newState.DrawOrder = drawOrder;

            AddState(newState);

            //Let everyone know we just changed states
            if (OnStateChange != null)
                OnStateChange(this, null);
        }
        public void ChangeState(GameState newState)
        {
            //We are changing states, so pop everything ...
            //if we don't want to really change states but just modify,
            //we should call PushState and PopState
            while (states.Count > 0)
                RemoveState();

            //changing state, reset our draw order
            newState.DrawOrder = drawOrder = initialDrawOrder;
            AddState(newState);

            //Let everyone know we just changed states
            if (OnStateChange != null)
                OnStateChange(this, null);
        }
        private void AddState(GameState state)
        {
            states.Push(state);

            Game.Components.Add(state);

            //Register the event for this state
            OnStateChange += state.StateChanged;
        }
 public bool ContainsState(GameState state)
 {
     return (states.Contains(state));
 }