Example #1
0
        public ParticleManager(int capacity, Action <Particle> updateMethod)
        {
            UpdateMethod = updateMethod;
            Particles    = new ParticleContainer(capacity);

            for (int i = 0; i < capacity; i++)
            {
                Particles[i] = new Particle();
            }
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            int removal = 0;

            for (int i = 0; i < Particles.Count; i++)
            {
                var p = Particles[i];
                UpdateMethod(p);
                p.LifeTime -= 1.0f / p.Duration;

                ParticleContainer.Swap(Particles, i - removal, i);
                if (p.LifeTime < 0)
                {
                    removal++;
                }
            }
            Particles.Count -= removal;
        }