public ExplosionEmitter(Vector2 position, Texture2D sprite, Color color)
        {
            this.position = position;
            this.sprite = sprite;
            this.particles = new List<Particle>(EXPLOSION_SIZE);
            this.color = color;
            Vector2 v;
            for (int i = 0; i < EXPLOSION_SIZE; i++)
            {
                v = new Vector2(random.Next(1000), random.Next(1000));
                v.Normalize();
                v *= (float)(random.Next(EXPLOSION_SPEED)*random.NextDouble());
                if (random.Next(3) > 1)
                {
                    v.X *= -1;
                }
                if (random.Next(3) > 1)
                {
                    v.Y *= -1;
                }
                Particle p = new Particle(v, position, 0, 0, random.Next(6) + 4, EXPLOSION_LENGTH, sprite, color);
                particles.Add(p);
                numberOfParticles++;
            }

        }
Exemplo n.º 2
0
 private Particle newPart()
 {
     Vector2 v = -0.04f * ((float)random.NextDouble())* enemy.Velocity;
     v = Vector2.Transform(v, Matrix.CreateRotationZ((float) (Math.PI*(0.35)*(random.NextDouble() - 0.5))));
     Vector2 p = enemy.Location;
     int s = random.Next(3)+3;
     int ttl = random.Next(15) + 1;
     Particle particle = new Particle(v, p, 0, 0, s, ttl, sprite, Color.HotPink);
     return particle;
 }
 private Particle newParticle()
 {
     Vector2 v = (float)random.NextDouble() * 0.05f * (new Vector2(random.Next(size), random.Next(size)));
     if (random.Next(3) > 1)
     {
         v.X *= -1;
     }
     if (random.Next(3) > 1)
     {
         v.Y *= -1;
     }
     Vector2 p = bullet.Location;
     int s = random.Next(3) + 3;
     int ttl = random.Next(50) + 1;
     Particle particle = new Particle(v, p, 0, 0, s, ttl, tex, Color.Red);
     return particle;
 }
Exemplo n.º 4
0
 private Particle newParticle()
 {
     Vector2 v = (float)random.NextDouble()*0.05f*(new Vector2(random.Next(size), random.Next(size)));
     if (random.Next(3) > 1)
     {
         v.X *= -1;
     }
     if (random.Next(3) > 1)
     {
         v.Y *= -1;
     }
     Vector2 p = position;
     float a = (float)random.NextDouble();
     float av = (float)random.NextDouble();
     int s = random.Next(3)+3;
     int ttl = random.Next(50)+1;
     Particle particle = new Particle(v, p, a, av, s, ttl, sprite, color);
     return particle;
 }