/// <summary>
        /// Generates a new particle at the specified position.
        /// </summary>
        /// <returns>A new particle.</returns>
        /// <param name="pos">The position of the object to create particles around.</param>
        public virtual Particle GenerateParticle(Vector2 pos)
        {
            Particle particle = Pool.GetParticle(_textures[_random.Next(_textures.Count)], pos);

            particle.Velocity           = _randomProperties.Speed.HasValue ? _randomProperties.Speed.Value : new Vector2((_random.NextDouble() * 2 - 1).ToFloat(), (_random.NextDouble() * 2 - 1).ToFloat());
            particle.AngularVelocity    = SpriteRotation.FromDegrees(_randomProperties.RotationChange.HasValue ? _randomProperties.RotationChange.Value : MathHelper.ToDegrees(Convert.ToSingle(_random.NextDouble() * 2 - 1) / 10f));
            particle.TintColor          = _randomProperties.Tint.HasValue ? _randomProperties.Tint.Value : new Color(_random.Next(255), _random.Next(255), _random.Next(255), _random.Next(255));
            particle.Scale              = _randomProperties.Scale.HasValue ? _randomProperties.Scale.Value : new Vector2(_random.NextDouble().ToFloat() / ScaleFactor);
            particle.TimeToLive         = _randomProperties.TimeToLive.HasValue ? _randomProperties.TimeToLive.Value : TimeSpan.FromTicks(_random.Next((int)_minTTL.Ticks, (int)_maxTTL.Ticks));
            particle.TimeToLiveSettings = _ttlSettings;

            if (_randomProperties.ColorFactor.HasValue)
            {
                particle.ColorChange = _randomProperties.ColorFactor.Value;
            }
            else if (_minumumParticleColorChangeRate != 1)
            {
                float particleColorDegenerationRate = _random.NextDouble().ToFloat();
                while (particleColorDegenerationRate < _minumumParticleColorChangeRate)
                {
                    particleColorDegenerationRate += Convert.ToSingle(_random.NextDouble() % 0.15);
                }
                particle.ColorChange = particleColorDegenerationRate;
            }

            particle.UseCenterAsOrigin = true;

            return(particle);
        }
Beispiel #2
0
        public void FromDegreesTest()
        {
            float          degrees  = 0F;                   // TODO: Initialize to an appropriate value
            SpriteRotation expected = new SpriteRotation(); // TODO: Initialize to an appropriate value
            SpriteRotation actual;

            actual = SpriteRotation.FromDegrees(degrees);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }