示例#1
0
 private void SaveEffectCtrl(EffectCtrl effectCtrl)
 {
     effectCtrl.End();
     this.gameObject.AddChildToParent(effectCtrl.gameObject);
     effectCtrl.gameObject.SetActive(false);
     m_queuePool.Enqueue(effectCtrl);
 }
示例#2
0
 private void DestroyEffect(EffectCtrl effect)
 {
     for (int i = m_lstEffect.Count - 1; i > -1; i--)
     {
         if (m_lstEffect[i] == effect)
         {
             m_lstEffect.RemoveAt(i);
             SaveEffectCtrl(effect);
         }
     }
 }
示例#3
0
 void Update()
 {
     for (int i = m_lstEffect.Count - 1; i > -1; i--)
     {
         if (!m_lstEffect[i].OnUpdate(Time.deltaTime))
         {
             EffectCtrl effectCtrl = m_lstEffect[i];
             m_lstEffect.RemoveAt(i);
             SaveEffectCtrl(effectCtrl);
         }
     }
 }
示例#4
0
        public void DestroyEffectGO(GameObject go)
        {
            EffectCtrl effectCtrl = go.GetComponent <EffectCtrl>();

            if (effectCtrl != null)
            {
                DestroyEffect(effectCtrl);
            }
            else
            {
                CLog.LogError("销毁特效的对象上必须有EffectCtrl脚本");
            }
        }
示例#5
0
 public void Clear()
 {
     for (int i = m_lstEffect.Count - 1; i > -1; i--)
     {
         EffectCtrl effectCtrl = m_lstEffect[i];
         m_lstEffect.RemoveAt(i);
         SaveEffectCtrl(effectCtrl);
     }
     m_lstEffect.Clear();
     for (int i = 0; i < m_lstPath.Count; i++)
     {
         GameObjectPool.Instance.Clear(m_lstPath[i]);
     }
     m_lstPath.Clear();
 }
示例#6
0
        public virtual GameObject CreateEffect(string path, bool autoDestory, Transform parent = null)
        {
            if (!m_lstPath.Contains(path))
            {
                m_lstPath.Add(path);
            }
            EffectCtrl effectCtrl = GetEffectCtrl();

            if (parent != null)
            {
                parent.gameObject.AddChildToParent(effectCtrl.gameObject);
            }
            m_lstEffect.Add(effectCtrl);
            effectCtrl.Begin(path, autoDestory);
            return(effectCtrl.gameObject);
        }
示例#7
0
        private EffectCtrl GetEffectCtrl()
        {
            EffectCtrl effectCtrl = null;

            if (m_queuePool.Count > 0)
            {
                effectCtrl = m_queuePool.Dequeue();
            }
            else
            {
                GameObject go = new GameObject("effect");
                this.gameObject.AddChildToParent(go);
                effectCtrl = go.AddComponentOnce <EffectCtrl>();
            }
            effectCtrl.gameObject.SetActive(true);
            return(effectCtrl);
        }