Beispiel #1
0
    void EffectPoolCreate(Transform parent, EffectType type, Data.EffectContainier containier)
    {
        m_effectPools[type] = new Dictionary <int, EffectPool>();

        for (int i = 0; i < containier.GetEffectCount(type); i++)
        {
            GameObject prefab = containier.GetEffects(type, i);
            if (prefab != null)
            {
                EffectPool pool = new EffectPool();
                pool.prefab        = prefab;
                pool.nBufferAmount = m_effectAmount;
                pool.pooledList    = new Stack <GameObject>();

                for (int j = 0; j < pool.nBufferAmount; j++)
                {
                    GameObject poolObj = Instantiate(prefab);
                    poolObj.name             = prefab.name;
                    poolObj.transform.parent = parent;
                    poolObj.SetActive(false);
                    pool.pooledList.Push(poolObj);
                }

                m_effectPools[type].Add(i, pool);
            }
        }
    }
Beispiel #2
0
    void InitEffectPools(Data.EffectContainier containier)
    {
        m_effectParent = new GameObject("Effects");
        m_effectParent.transform.parent = transform;

        EffectPoolCreate(m_effectParent.transform, EffectType.Particle, containier);

        EffectPoolCreate(m_effectParent.transform, EffectType.Projectile, containier);
    }