Exemplo n.º 1
0
        public void WasShot()
        {
            IsExpired = true;
            PlayerStatus.AddPoints(PointValue);
            PlayerStatus.IncreaseMultiplier();

            float hue1   = rand.NextFloat(0, 6);
            float hue2   = (hue1 + rand.NextFloat(0, 2)) % 6f;
            Color color1 = ColorUtil.HSVToColor(hue1, 0.5f, 1);
            Color color2 = ColorUtil.HSVToColor(hue2, 0.5f, 1);

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

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

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
        }
Exemplo n.º 2
0
        public void WasShot()
        {
            hitpoints--;
            if (hitpoints <= 0)
            {
                IsExpired = true;
                PlayerStatus.AddPoints(5);
                PlayerStatus.IncreaseMultiplier();
            }


            float     hue          = (float)((3 * GameRoot.GameTime.TotalGameTime.TotalSeconds) % 6);
            Color     color        = ColorUtil.HSVToColor(hue, 0.25f, 1);
            const int numParticles = 150;
            float     startOffset  = rand.NextFloat(0, MathHelper.TwoPi / numParticles);

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

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, pos, color, 90, 1.5f, state);
            }

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Kills an enemy
        /// </summary>
        /// <param name="isNewLife">Checks to see whether or not the player died and the enemy needs to
        ///                         be killed without generating new subenemies. False by default</param>
        public void KillEnemy(bool isNewLife = false)
        {
            // Expire the entity
            IsExpired = true;

            // Check to see if the enemy was not killed by virtue of a new life
            if (!isNewLife)
            {
                // Add points and increase the multiplier
                PlayerStatus.AddPoints(PointValue);
                PlayerStatus.IncreaseMultiplier();

                // Create 2 random hues
                float hue1 = rand.NextFloat(0, 6);
                float hue2 = (hue1 + rand.NextFloat(0, 2)) % 6f;

                // Extract the colours from the two hues
                Color color1 = ColorUtil.HSVToColor(hue1, 0.5f, 1);
                Color color2 = ColorUtil.HSVToColor(hue2, 0.5f, 1);

                // Create a particle explosion of 120 particles
                for (int i = 0; i < 120; i++)
                {
                    // Set the particle speed
                    float speed = 18f * (1f - 1 / rand.NextFloat(1, 10));

                    // Create a new particle state
                    var state = new ParticleState()
                    {
                        Velocity         = rand.NextVector2(speed, speed),
                        Type             = ParticleType.Enemy,
                        LengthMultiplier = 1
                    };

                    // Lerp the colour between the two colours defined above
                    Color color = Color.Lerp(color1, color2, rand.NextFloat(0, 1));

                    // Create the particle
                    GameBase.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
                }

                // Play an explosion sound
                Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);

                // NOTE: I use different X velocities to add to the illusion of weight
                // If the enemy is a large meteor, spawn in two middle meteors
                if (Type == EnemyType.LargeMeteor)
                {
                    EntityManager.Add(MiddleMeteor(Position, new Vector2(5, -6)));
                    EntityManager.Add(MiddleMeteor(Position, new Vector2(-5, -6)));
                }
                // If the enemy is a middle meteor, spawn in two small meteors
                else if (Type == EnemyType.MiddleMeteor)
                {
                    EntityManager.Add(SmallMeteor(Position, new Vector2(7, -6)));
                    EntityManager.Add(SmallMeteor(Position, new Vector2(-7, -6)));
                    EntityManager.Add(SmallMeteor(Position, new Vector2(0, 6)));
                }
            }
        }
Exemplo n.º 4
0
        public void WasShot()
        {
            IsExpired = true;
            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);

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