Exemplo n.º 1
0
        virtual public void Initialize()
        {
            if (m_hasEvents)
            {
                OnStart.Dispatch();
            }

            if (!m_initialized)
            {
                m_engine       = AFEngine.Instance;
                m_stateManger  = AFEngine.Instance.GetStateManger();
                m_soundManager = AFSoundManager.Instance;
                m_assetManager = AFAssetManager.Instance;
                m_input        = AFInput.Instance;
                m_objects      = new List <AFObject>();
                m_gameObjects  = new List <GameObject>();

                if (m_hasEvents)
                {
                    OnInitialized.Dispatch();
                }
                BuildState();
                m_initialized = true;
            }
            else
            {
                Resume();
            }
        }
Exemplo n.º 2
0
        virtual public void Destroy()
        {
            if (m_destroyable)
            {
                m_stateManger  = null;
                m_soundManager = null;
                m_input        = null;
                m_engine       = null;
                m_assetManager = null;

                for (int i = 0; i < m_objects.Count; ++i)
                {
                    Destroy(m_objects[i].gameObject);
                }

                m_objects.Clear();
                m_objects = null;
            }
            else
            {
                Debug.LogWarning("State could not be destroyed, set the destroyable value to true for complete the action");
            }

            if (m_hasEvents)
            {
                OnDestroy.Dispatch();
            }
        }
Exemplo n.º 3
0
        virtual public void Initialize(IStateFactory factory)
        {
            //TODO: Verify if factory is null case yes throw some error
            m_factory = factory;
            m_engine  = AFEngine.Instance;

            AddTransition(new AFDefaultStateTransition());
        }
Exemplo n.º 4
0
        override public void AFDestroy()
        {
            m_stateManger  = null;
            m_soundManager = null;
            m_assetManager = null;
            m_input        = null;
            m_engine       = null;

            for (int i = 0; i < m_objects.Count; ++i)
            {
                m_objects[i].AFDestroy();
            }

            for (int i = 0; i < m_gameObjects.Count; ++i)
            {
                if (AFObject.IsNull(m_gameObjects[i]))
                {
                    Destroy(m_gameObjects[i]);
                }
            }

            m_objects.Clear();
            m_objects = null;

            OnStart.RemoveAll();
            OnStart = null;

            OnDestroy.RemoveAll();
            OnDestroy = null;

            OnInitialized.RemoveAll();
            OnInitialized = null;

            OnPause.RemoveAll();
            OnPause = null;

            OnObjectAdded.RemoveAll();
            OnObjectAdded = null;

            OnObjectRemoved.RemoveAll();
            OnObjectRemoved = null;

            base.AFDestroy();
        }