示例#1
0
 private void ResetTransitions()
 {
     currentTransition = null;
     nextTransition = null;
     nextState = null;
 }
示例#2
0
        public void Push(BaseGameState state, ITransition transOut = null, ITransition transIn = null)
        {
            pushNextState = true;

            pushBuffer = state;
            TransitionToNextState(transOut, transIn);
        }
示例#3
0
        private void PushState()
        {
            // No states? set the state
            if (states.Count <= 0 && nextState == null)
            {
                nextState = pushBuffer;
                pushBuffer = null;

                SetState();
                return;
            }

            // Our new state is full screen, the previous states have lost focus
            if (!pushBuffer.IsOverlay)
            {
                foreach (var state in states)
                    state.OnLostFocus();
            }

            markToPush.Enqueue (pushBuffer);
        }
示例#4
0
        private void PopState()
        {
            bool needNewInputReceiver = states[states.Count - 1] == latestInputReceiver;

            states[states.Count-1].OnLostFocus();
            states.RemoveAt (states.Count-1);

            if (needNewInputReceiver)
                latestInputReceiver = FindInputReceiver ();
        }
示例#5
0
        public void Update(GameTime gameTime)
        {
            // TODO: Find a better way to handle this
            latestInputReceiver = FindInputReceiver();
            if (latestInputReceiver != null)
                latestInputReceiver.HandleInput (gameTime);

            foreach (var state in states)
                state.Update (gameTime);

            if (currentTransition != null)
                UpdateTransition(gameTime);

            //  Pop all marked states, you can't do this during Update()
            if (markToPopCount > 0)
            {
                for (int i=0; i < markToPopCount; i++)
                    PopState();

                markToPopCount = 0;
            }

            // Set state
            if (nextState != null)
            {
                foreach (var state in states)
                    state.OnLostFocus ();

                states.Clear ();
                states.Add (nextState);
                nextState.OnFocus ();

                nextState = null;
            }

            // Push all new states on to the stack outside of Update()
            while (markToPush.Count > 0)
            {
                states.Add (markToPush.Dequeue ());
                CurrentState.OnFocus();
            }
        }
示例#6
0
        public void Set(string name, ITransition transOut = null, ITransition transIn = null)
        {
            pushNextState = false;

            nextState = stateMap[name];
            TransitionToNextState (transOut, transIn);
        }
示例#7
0
        public void Push(string name, ITransition transOut = null, ITransition transIn = null)
        {
            pushNextState = true;

            pushBuffer = stateMap[name];
            TransitionToNextState (transOut, transIn);
        }