Пример #1
0
        /// <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);
        }
Пример #2
0
        protected void SetSprite(BulletSpriteIdentifier identifier)
        {
            switch (identifier)
            {
            case BulletSpriteIdentifier.OVAL_SMALL:
            case BulletSpriteIdentifier.OVAL_LARGE:
                _spriteRotation = SpriteRotation.ROTATE;
                break;

            case BulletSpriteIdentifier.STAR_SMALL:
            case BulletSpriteIdentifier.STAR_LARGE:
                _spriteRotation = SpriteRotation.SPIN;
                break;

            default:
                _spriteRotation = SpriteRotation.NONE;
                break;
            }
            if (identifier == BulletSpriteIdentifier.NONE)
            {
                _spriteRenderer.sprite = null;
                return;
            }
            _spriteRenderer.sprite = _spriteDictionary[identifier];
        }
Пример #3
0
        public void SpriteRotationConstructorTest1()
        {
            float          value           = 0F;              // TODO: Initialize to an appropriate value
            AngleType      measurementType = new AngleType(); // TODO: Initialize to an appropriate value
            SpriteRotation target          = new SpriteRotation(value, measurementType);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Пример #4
0
        public void SpriteRotationConstructorTest0()
        {
            float          degrees = 360F;
            SpriteRotation target  = new SpriteRotation(degrees);

            Assert.AreEqual(MathHelper.TwoPi, target.Radians);
            Assert.AreEqual(degrees, target.Degrees);
            Assert.AreEqual(324.0f, target.Gradians, 0.075f);
        }
Пример #5
0
        public void FromRadiansTest()
        {
            float          radians  = MathHelper.PiOver2;     // TODO: Initialize to an appropriate value
            SpriteRotation expected = new SpriteRotation(90); // TODO: Initialize to an appropriate value
            SpriteRotation actual;

            actual = SpriteRotation.FromRadians(radians);
            Assert.AreEqual(expected, actual);
        }
Пример #6
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.");
        }
Пример #7
0
        public void op_SubtractionTest()
        {
            SpriteRotation x        = new SpriteRotation(360); // TODO: Initialize to an appropriate value
            float          y        = 180F;                    // TODO: Initialize to an appropriate value
            SpriteRotation expected = new SpriteRotation(180); // TODO: Initialize to an appropriate value
            SpriteRotation actual;

            actual = (x - y);
            Assert.AreEqual(expected.Degrees, actual.Degrees, 0.075f);
        }
Пример #8
0
        public void op_AdditionTest()
        {
            SpriteRotation x        = new SpriteRotation(90);                               // TODO: Initialize to an appropriate value
            SpriteRotation y        = new SpriteRotation(MathHelper.Pi, AngleType.Radians); // TODO: Initialize to an appropriate value
            SpriteRotation expected = new SpriteRotation(270);                              // TODO: Initialize to an appropriate value
            SpriteRotation actual;

            actual = (x + y);
            Assert.AreEqual(expected, actual);
        }
Пример #9
0
        public void RadiansTest()
        {
            SpriteRotation target   = new SpriteRotation();
            float          expected = 0F;
            float          actual;

            target.Radians = expected;
            actual         = target.Radians;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #10
0
        public void DegreesTest()
        {
            SpriteRotation target   = new SpriteRotation(); // TODO: Initialize to an appropriate value
            float          expected = 0F;                   // TODO: Initialize to an appropriate value
            float          actual;

            target.Degrees = expected;
            actual         = target.Degrees;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #11
0
        public void op_SubtractionTest1()
        {
            SpriteRotation x        = new SpriteRotation(); // TODO: Initialize to an appropriate value
            SpriteRotation y        = new SpriteRotation(); // TODO: Initialize to an appropriate value
            SpriteRotation expected = new SpriteRotation(); // TODO: Initialize to an appropriate value
            SpriteRotation actual;

            actual = (x - y);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #12
0
        public void op_LessThanTest()
        {
            SpriteRotation x        = new SpriteRotation(); // TODO: Initialize to an appropriate value
            SpriteRotation y        = new SpriteRotation(); // TODO: Initialize to an appropriate value
            bool           expected = false;                // TODO: Initialize to an appropriate value
            bool           actual;

            actual = (x < y);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #13
0
        public void GradiansTest()
        {
            SpriteRotation target   = new SpriteRotation();
            float          expected = 323.1F;
            float          actual;

            target.Gradians = expected;
            actual          = target.Gradians;
            Assert.AreEqual(expected, actual, 0.075F);
            Assert.AreEqual(target.Degrees, 359);
            Assert.AreEqual(target.Radians, MathHelper.TwoPi - MathHelper.ToRadians(1));
        }
Пример #14
0
        public void op_LessThanOrEqualTest()
        {
            SpriteRotation x        = new SpriteRotation(100); // TODO: Initialize to an appropriate value
            SpriteRotation y        = new SpriteRotation(100); // TODO: Initialize to an appropriate value
            bool           expected = true;                    // TODO: Initialize to an appropriate value
            bool           actual;

            actual = (x <= y);

            Assert.AreEqual(expected, actual);


            Assert.AreEqual(false, ((x + y) <= y));
        }
Пример #15
0
            public TilingRule()
            {
                m_Output         = OutputSprite.Single;
                m_Neighbors      = new Neighbor[8];
                m_Sprites        = new Sprite[1];
                m_AnimationSpeed = 1f;
                m_PerlinScale    = 0.5f;
                m_ColliderType   = Tile.ColliderType.Sprite;

                spriteRotation = SpriteRotation.Default;

                for (int i = 0; i < m_Neighbors.Length; i++)
                {
                    m_Neighbors[i] = Neighbor.DontCare;
                }
            }
Пример #16
0
        public void op_GreaterThanOrEqualTest()
        {
            SpriteRotation x         = new SpriteRotation(10);    // TODO: Initialize to an appropriate value
            SpriteRotation y         = new SpriteRotation(10.5f); // TODO: Initialize to an appropriate value
            bool           expected  = false;                     // TODO: Initialize to an appropriate value
            bool           expected2 = true;
            bool           actual2;

            actual2 = (y >= x);

            bool actual;

            actual = (x >= y);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(expected2, actual2);
        }