Esempio n. 1
0
        public void RequestChangeState(System.Type state)
        {
            if (m_CurrentStateHandler != null && m_CurrentStateHandler.GetType() == state)
            {
                return;
            }

            int stateIndex = CheckHasPotentialState(state);

            if (stateIndex == -1)
            {
                return;
            }


            StateHandlerBase lastState = m_CurrentStateHandler;

            m_CurrentStateHandler = m_Potential.States [stateIndex].Construct(m_Facade);

            if (lastState != null)
            {
                lastState.OnExit(m_CurrentStateHandler);
            }

            m_CurrentStateHandler.OnEnter(lastState);
        }
Esempio n. 2
0
        public void RequestChangeState <T>() where T : StateHandlerBase
        {
            if (m_CurrentStateHandler != null && m_CurrentStateHandler is T)
            {
                return;
            }

            int stateIndex = CheckHasPotentialState <T> ();

            if (stateIndex == -1)
            {
                return;
            }

            StateHandlerBase lastState = m_CurrentStateHandler;

            m_CurrentStateHandler = m_Potential.States[stateIndex].Construct(m_Facade);

            if (lastState != null)
            {
                lastState.OnExit(m_CurrentStateHandler);
            }

            m_CurrentStateHandler.OnEnter(lastState);
        }
 public abstract void OnExit(StateHandlerBase nextState = null);
 public abstract void OnEnter(StateHandlerBase lastState = null);