예제 #1
0
        public static IEffect Get(int index, EEffectGroup group = EEffectGroup.Base)
        {
            IEffect ef;

#if UNITY_EDITOR
            if (m_instance.m_dic[(int)group].ContainsKey(index))
            {
                ef = m_instance.m_dic[(int)group][index].Get();
            }
            else
            {
                Debug.Log.i(ELogType.Effect, "LaoHan:EffectManager dont has this index;" + index + "    " + group);
                var pool = new EffectPool();
                pool.index      = index;
                pool.storeCount = 1;
                m_instance.m_dic[(int)group].Add(index, pool);
                pool.loadHandler = m_instance.loadHandler;
                pool.group       = group;
                pool.Initialize(() => { });
                ef = m_instance.m_dic[(int)group][index].Get();
            }
#else
            ef = m_instance.m_dic[(int)group][index].Get();
#endif
            if (getHandler != null)
            {
                getHandler(index);
            }
            return(ef);
        }
예제 #2
0
        public static void Store(int index, int count, EEffectGroup group, int capacity = -1, EventHandler onStoreHandler = null)
        {
            var g = m_instance.m_dic[(int)group];

            if (g.ContainsKey(index))
            {
                g[index].Add(count);
                if (onStoreHandler != null)
                {
                    onStoreHandler();
                }
            }
            else
            {
                var pool = new EffectPool();
                pool.index      = index;
                pool.capacity   = capacity;
                pool.storeCount = count;
                g.Add(index, pool);
                pool.loadHandler = m_instance.loadHandler;
                pool.group       = group;
                pool.Initialize(onStoreHandler);
            }
            if (storeHandler != null)
            {
                storeHandler(index);
            }
        }