public void GenerateExplosion(Vector2 center, float radius)
        {
            if (Textures.Count == 0)
                throw new Exception("ExplosionParticlesLogic() -> Textures not set!");

            var firesCount = Random.Next(MinNumParticles, MaxNumParticles);
            for (var i = 0; i < firesCount; i++)
            {
                var direction = PickRandomDirection();
                var scale = RandomBetween(MinScale, MaxScale);
                var p = new Particle
                {
                    Texture = Textures[Random.Next(0, Textures.Count - 1)],
                    Position = center,
                    Lifetime = RandomBetween(MinLifetime, MaxLifetime),
                    Velocity = RandomBetween(MinInitialSpeed, MaxInitialSpeed) * direction,
                    InitialScale = new Vector2(scale, scale),
                    Direction = direction,
                    Acceleration = RandomBetween(MinAcceleration, MaxAcceleration) * direction,
                    RotationSpeed = RandomBetween(MinRotationSpeed, MaxRotationSpeed)
                };
                p.Acceleration = -p.Velocity / p.Lifetime;

                Particles.Add(p);
            }
        }
 /// <summary>
 /// Generates particle object that represents afterburner cloud
 /// </summary>
 /// <param name="startPosition">Cloud start position</param>
 /// <param name="rotation">Host object rotation (to determine cloud shot direction)</param>
 public void GenerateParticle(Vector2 startPosition, float rotation)
 {
     var p = new Particle {Texture = Textures[0], Position = startPosition, Direction = Vector2.Transform(_upDirection, Matrix.CreateRotationZ(rotation))};
     //generate afterburner cloud shot direction
     //set AB shot initial velocity
     p.Velocity = -p.Direction * 6f;
     //set AB cloud initial scale
     p.Scale = Vector2.One * 0.9f;
     //set time to live
     p.Lifetime = 8000;
     p.LogicId = LogicId;
     Particles.Add(p);
     OnParticleCreated(p);
 }
 /// <summary>
 /// Generates particle object that  represents laser beam
 /// </summary>
 /// <param name="startPosition">Beam start position</param>
 /// <param name="rotation">Host object rotation (to determine beam direction)</param>
 public void GenerateBeam(Vector2 startPosition, float rotation)
 {
     var p = new Particle { Texture = Textures[0], Position = startPosition };
     //modifier for different beam spreading
     var mod = _rnd.Next(1) == 0 ? -1 : 1;
     //determine slightly spreaded rotation
     p.Rotation = rotation + (float)_rnd.NextDouble() * .2f * mod;
     //get direction from rotation radian angle
     p.Direction = Vector2.Transform(_upDirection, Matrix.CreateRotationZ(p.Rotation));
     //set final velocity
     p.Velocity = p.Direction * 15f;
     //set time to live
     p.Lifetime = 8000;
     p.LogicId = LogicId;
     Particles.Add(p);
     OnParticleCreated(p);
 }
 internal void OnParticleCreated(Particle p)
 {
     if (ParticleCreated != null)
         ParticleCreated(p);
 }