Ejemplo n.º 1
0
        public void Update(long delta)
        {
            if ((sprite == null) && (defaultImageName != null))
            {
                LoadSystemParticleImage();
            }

            removeMe.Clear();
            List <ParticleEmitter> emitters = new List <ParticleEmitter>(
                this.emitters);

            for (int i = 0; i < emitters.Count; i++)
            {
                ParticleEmitter emitter = emitters[i];
                if (emitter.IsEnabled())
                {
                    emitter.Update(this, delta);
                    if (removeCompletedEmitters)
                    {
                        if (emitter.Completed())
                        {
                            removeMe.Add(emitter);
                            particlesByEmitter.Remove(emitter);
                        }
                    }
                }
            }
            CollectionUtils.RemoveAll(emitters, removeMe);

            pCount = 0;

            if (particlesByEmitter.Count != 0)
            {
                IEnumerator <ParticleEmitter> it = particlesByEmitter.Keys
                                                   .GetEnumerator();
                while (it.MoveNext())
                {
                    ParticleEmitter emitter = it.Current;
                    if (emitter.IsEnabled())
                    {
                        ParticlePool pool = particlesByEmitter[emitter];
                        for (int i = 0; i < pool.particles.Length; i++)
                        {
                            if (pool.particles[i].life > 0)
                            {
                                pool.particles[i].Update(delta);
                                pCount++;
                            }
                        }
                    }
                }
            }
        }