Exemple #1
0
        public void Update(float timestamp)
        {
            if (m_pStatePoped != null)
            {
                m_pStatePoped.Pause();
                m_pStatePoped.Release();
                m_stateIndex--;

                if (m_stateIndex >= 0)
                {
                    m_pStateStack[m_stateIndex].Resume();
                }
                ResetTouch();

                m_pStatePoped = null;
            }

            if (m_pStatePushed.Count > 0)
            {
                gxGameState pState = m_pStatePushed.Pop();

                if (pState == null)
                {
                    Common.UDebug.Assert(false, "Tried to add a NULL state !!!");
                    ClearStateStack();
                }

                Common.UDebug.Assert(m_stateIndex < GAME_STATES_STACK_SIZE);

                gxGameState oldState = CurrentState();
                if (oldState != null)
                {
                    oldState.Pause();
                }
                m_stateIndex++;
                m_pStateStack[m_stateIndex] = pState;

                if (pState.Initalize() < 0)
                {
                    Common.UDebug.Assert(false, "Failed to create the current state!!!!");
                    ClearStateStack();
                }
                else
                {
                    pState.Resume();
                    pState.SetLoading(true);
                }
                ResetTouch();
            }

            if (m_stateIndex < 0)
            {
                return;
            }
            if (m_pStateStack[m_stateIndex].IsLoading())
            {
                m_pStateStack[m_stateIndex].SetLoading(m_pStateStack[m_stateIndex].Load());
            }
            else
            {
                m_pStateStack[m_stateIndex].Update(timestamp);
            }
        }