示例#1
0
 public void Reset()
 {
     Position     = new Vector2(0);
     Acceleration = new Vector2(_randomizer.Next(0, 20), _randomizer.Next(0, 20));
     //Acceleration = new Vector2(1,1);
     Speed           = 100;
     Speed           = (_randomizer.NextFloat() + 1) * 50;
     Size            = new Vector2(_randomizer.NextFloat() + 0.3f);
     AngularVelocity = (_randomizer.NextFloat() / 4f) - .125f;
 }
        private Particle GenerateNewParticle(List <Color> colors)
        {
            Texture2D texture  = _textures[_random.Next(_textures.Count)];
            Vector2   position = EmitterLocation;
            Vector2   velocity = new Vector2(
                1f * (float)(_random.NextFloat() * 2 - 1),
                1f * (float)(_random.NextFloat() * 2 - 1));
            float angle           = 0;
            float angularVelocity = 0.1f * (float)(_random.NextFloat() * 2 - 1);

            var color = colors[_random.Next(colors.Count)];
            //Color color = new Color(
            //    (float)random.NextFloat(),
            //    (float)random.NextFloat(),
            //    (float)random.NextFloat());
            //var color = Color.LightGray;

            float size = (float)_random.NextFloat();
            int   ttl  = 20 + _random.Next(40);

            return(new Particle(texture, position, velocity, angle, angularVelocity, color, size, ttl));
        }