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(); } }
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(); } }
/// <summary> /// <para> /// This method destroys all states and yours objects /// </para> /// </summary> virtual public void Destroy() { m_startTime = 0; m_time = 0; m_deltaTime = 0; OnPause.RemoveAll(); OnPause = null; OnEngineReady.RemoveAll(); OnEngineReady = null; OnApplicationFocusChange.RemoveAll(); OnApplicationFocusChange = null; OnApplicationExit.RemoveAll(); OnApplicationExit = null; OnApplicationDestroy.RemoveAll(); OnApplicationDestroy = null; m_input.AFDestroy(); m_input = null; m_soundManager.AFDestroy(); m_soundManager = null; m_stateManager.AFDestroy(); m_stateManager = null; }
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(); }