Example #1
0
        private void ChangeState()
        {
            if (!currentStateID.Equals(AState.EGameState.NULL))
            {
                if (m_currentState.IsDestroyable())
                {
                    m_currentState.AFDestroy();

                    if (m_currentState is AState)
                    {
                        Destroy((m_currentState as AState).gameObject);
                    }
                }
                else
                {
                    m_currentState.Pause();
                }
            }

            currentStateID = m_nextStateID;
            m_currentState = GetState(m_nextStateID);
            m_nextStateID  = AState.EGameState.NULL;

            if (m_currentState is AState)
            {
                (m_currentState as AState).transform.parent = gameObject.transform;
            }

            m_currentState.Initialize();

            m_transition.End();
        }