示例#1
0
        public void BuildPools(int poolSize)
        {
            if (explosionCollection == null)
            {
                explosionCollection = new Dictionary <BaseExplosion, ObjectPool <GameObject> >();
            }

            int nExplosions = explosions.Length;

            for (int i = 0; i < nExplosions; i++)
            {
                BaseExplosion currentExplosion = explosions[i];
                PoolManager.BuildPool(currentExplosion.ParticleSysPrefab, poolSize);
                ObjectPool <GameObject> itemsPool = PoolManager.GetPool(currentExplosion.ParticleSysPrefab);
                explosionCollection[currentExplosion] = itemsPool;
            }
            //poolsBuilt = true;
        }
示例#2
0
        public void Explode(ExplosionType type, Vector3 position)
        {
            for (int i = 0; i < explosions.Length; i++)
            {
                BaseExplosion currentExplosion = explosions[i];

                if (currentExplosion.ExplosionType == type)
                {
                    var clone = PoolManager.SpawnObject(currentExplosion.ParticleSysPrefab);
                    if (clone == null)
                    {
                        return;
                    }
                    ParticleSystem ps = clone.GetComponent <ParticleSystem>();
                    ps.transform.position = position;

                    currentExplosion.ExplosionFinished += (s, e) => ExplosionDie(clone);
                    currentExplosion.Explode(currentExplosion.SoundFX, ps, position);
                    return;
                }
            }
        }