private void CreateExplosionParticle()
 {
     var state = new ParticleState
     {
         Velocity = Random.NextVector(0, 9),
         Type = ParticleType.Bullet,
         LengthMultiplier = 1
     };
     GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, Color.LightBlue, 50, 1, state);
 }
Exemple #2
0
        public void WasShot()
        {
            IsExpired = true;

            var hue1 = Random.NextFloat(0, 6);
            var hue2 = (hue1 + Random.Next(0, 2)) %6f;
            var color1 = ColorUtil.HsvToColor(hue1, 0.5f, 1);
            var color2 = ColorUtil.HsvToColor(hue2, 0.5f, 1);

            for (var i = 0; i < 120; i++)
            {
                var speed = 18f * (1f - 1 / Random.NextFloat(1, 10));
                var state = new ParticleState
                {
                    Velocity = Random.NextVector(speed, speed),
                    Type = ParticleType.Enemy,
                    LengthMultiplier = 1
                };

                var color = Color.Lerp(color1, color2, Random.NextFloat(0, 1));
                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
            }

            PlayerStatus.AddPoints(PointValue);
            PlayerStatus.IncreaseMultiplier();

            Sound.Explosion.Play(0.5f, Random.NextFloat(-0.2f, 0.2f), 0);
        }
        private void CreateExplosion()
        {
            var hue = (float)((3 * GameRoot.GameTime.TotalGameTime.TotalSeconds) % 6);
            var color = ColorUtil.HsvToColor(hue, 0.25f, 1);
            const int numParticles = 150;
            var startOffset = Random.NextFloat(0, MathHelper.TwoPi / numParticles);

            for (var i = 0; i < numParticles; i++)
            {
                var sprayVelocity = MathUtil.FromPolar(MathHelper.TwoPi * i / numParticles + startOffset, Random.NextFloat(8, 16));
                var position = Position + 2f * sprayVelocity;
                var state = new ParticleState
                {
                    Velocity = sprayVelocity,
                    Type = ParticleType.IgnoreGravity,
                    LengthMultiplier = 1
                };

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, position, color, 90, 1.5f, state);
            }
        }
        private void SprayOrbitingParticles()
        {
            var velocity = MathUtil.FromPolar(sprayAngle, Random.NextFloat(12, 15));
            var color = ColorUtil.HsvToColor(5, 0.5f, 0.8f);
            var position = Position + 2f * new Vector2(velocity.Y, -velocity.X) + Random.NextVector(4, 8);
            var state = new ParticleState
            {
                Velocity = velocity,
                LengthMultiplier = 1,
                Type = ParticleType.Enemy
            };

            GameRoot.ParticleManager.CreateParticle(Art.LineParticle, position, color, 190, 1.5f, state);

            sprayAngle -= MathHelper.TwoPi / 50f;
        }