public void Simulate(float duration)
        {
            var steps = duration / Interval;

            for (var i = 0; i < steps; i++)
            {
                for (int j = 0; j < Amount; j++)
                {
                    // create the particle
                    var particle = new Particle();
                    var pos      = Entity.Position + Position + Calc.Random.Range(-Range, Range);
                    if (Direction.HasValue)
                    {
                        particle = Type.Create(ref particle, pos, Direction.Value);
                    }
                    else
                    {
                        particle = Type.Create(ref particle, pos);
                    }
                    particle.Track = Track;

                    // simulate for a duration
                    var simulateFor = duration - Interval * i;
                    if (particle.SimulateFor(simulateFor))
                    {
                        System.Add(particle);
                    }
                }
            }
        }
示例#2
0
 public void Emit(ParticleType type, Entity track, int amount, Vector2 position, Vector2 positionRange, float direction)
 {
     for (int i = 0; i < amount; i++)
     {
         type.Create(ref particles[nextSlot], track, Calc.Random.Range(position - positionRange, position + positionRange), direction, type.Color);
         nextSlot = (nextSlot + 1) % particles.Length;
     }
 }
示例#3
0
 public void Emit(ParticleType type, Vector2 position)
 {
     type.Create(ref particles[nextSlot], position);
     nextSlot = (nextSlot + 1) % particles.Length;
 }
示例#4
0
 public void Emit(ParticleType type, Vector2 position, Color color, float direction)
 {
     type.Create(ref particles[nextSlot], position, color, direction);
     nextSlot = (nextSlot + 1) % particles.Length;
 }
 public void Emit(ParticleType type, Vector2 position, float direction)
 {
     type.Create(ref particles[nextSlot], position, direction);
     nextSlot = (nextSlot + 1) % particles.Length;
 }
示例#6
0
 public void Emit(ParticleType type, Vector2 position, float direction)
 {
     particles[GetParticleSlot()] = type.Create(position, direction);
 }