public void WasShot()
        {
            hitpoints--;
            if (hitpoints <= 0)
            {
                IsExpired = true;
                PlayerStatus.AddPoints(5);
                PlayerStatus.IncreaseMultiplier();
            }


            float     hue          = (float)((3 * NeonShooterGame.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
                };

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

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
        }
Exemple #2
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));
                NeonShooterGame.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
            }

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
        }
        public static ParticleState GetRandom(float minVel, float maxVel)
        {
            var state = new ParticleState();

            state.Velocity         = rand.NextVector2(minVel, maxVel);
            state.Type             = ParticleType.None;
            state.LengthMultiplier = 1;

            return(state);
        }
Exemple #4
0
        public override void Update()
        {
            var entities = EntityManager.GetNearbyEntities(Position, 250);

            // The black holes spray some orbiting particles. The spray toggles on and off every quarter second.
            if ((GameRoot.GameTime.TotalGameTime.Milliseconds / 250) % 2 == 0)
            {
                var sprayVel = MathUtil.FromPolar(sprayAngle, rand.NextFloat(12, 15));
                var color    = ColorUtil.HSVToColor(5, 0.5f, 0.8f); // light purple
                var pos      = Position + 2f * new Vector2(sprayVel.Y, -sprayVel.X) + rand.NextVector2(4, 8);
                var state    = new ParticleState(sprayVel, ParticleType.Enemy);

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, pos, color, 60, new Vector2(0.7f, 0.7f), state);
            }
            GameRoot.WarpingGrid.ApplyImplosiveForce(100f, new Vector3(Position.X, Position.Y, 0f), 20f);
            // rotate the spray direction
            sprayAngle -= MathHelper.TwoPi / 50f;
            foreach (var entity in entities)
            {
                if (entity is Enemy && !(entity as Enemy).IsActive)
                {
                    continue;
                }

                // bullets are repelled by black holes and everything else is attracted
                if (entity is Bullet)
                {
                    entity.Velocity += (entity.Position - Position).ScaleTo(0.3f);
                }
                else
                {
                    var dPos   = Position - entity.Position;
                    var length = dPos.Length();

                    entity.Velocity += dPos.ScaleTo(MathHelper.Lerp(2, 0, length / 250f));
                }
            }
            if (_isDying)
            {
                _frameRemainBeforeDie--;
                if (_frameRemainBeforeDie % 6 == 0)
                {
                    CreateExplosiveParticle();
                }
                if (_frameRemainBeforeDie <= 0)
                {
                    IsExpired = true;
                }
            }
        }
        public override void Update()
        {
            var entities = EntityManager.GetNearbyEntities(Position, 250);

            foreach (var entity in entities)
            {
                if (entity is Enemy && !(entity as Enemy).IsActive)
                {
                    continue;
                }

                // bullets are repelled by black holes and everything else is attracted
                if (entity is Bullet)
                {
                    entity.Velocity += (entity.Position - Position).ScaleTo(0.3f);
                }
                else
                {
                    var dPos   = Position - entity.Position;
                    var length = dPos.Length();

                    entity.Velocity += dPos.ScaleTo(MathHelper.Lerp(2, 0, length / 250f));
                }
            }

            // The black holes spray some orbiting particles. The spray toggles on and off every quarter second.
            if ((NeonShooterGame.GameTime.TotalGameTime.Milliseconds / 250) % 2 == 0)
            {
                Vector2 sprayVel = MathUtil.FromPolar(sprayAngle, rand.NextFloat(12, 15));
                Color   color    = ColorUtil.HSVToColor(5, 0.5f, 0.8f);                 // light purple
                Vector2 pos      = Position + 2f * new Vector2(sprayVel.Y, -sprayVel.X) + rand.NextVector2(4, 8);
                var     state    = new ParticleState()
                {
                    Velocity         = sprayVel,
                    LengthMultiplier = 1,
                    Type             = ParticleType.Enemy
                };

                NeonShooterGame.ParticleManager.CreateParticle(Art.LineParticle, pos, color, 190, 1.5f, state);
            }

            // rotate the spray direction
            sprayAngle -= MathHelper.TwoPi / 50f;

            NeonShooterGame.Grid.ApplyImplosiveForce((float)Math.Sin(sprayAngle / 2) * 10 + 20, Position, 200);
        }
Exemple #6
0
        private void CreateExplosiveParticle()
        {
            var       hue           = (float)((3 * GameRoot.GameTime.TotalGameTime.TotalSeconds) % 6);
            var       particleColor = ColorUtil.HSVToColor(hue, 0.25f, 1);
            const int numParticles  = 150;
            var       startOffset   = rand.NextFloat(0, MathHelper.TwoPi / numParticles);

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
            for (var i = 0; i < numParticles; i++)
            {
                var sprayVel = MathUtil.FromPolar(MathHelper.TwoPi * i / numParticles + startOffset, rand.NextFloat(8, 16));
                var pos      = Position + 2f * sprayVel;
                var state    = new ParticleState(sprayVel, ParticleType.Bullet);

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, pos, particleColor, 180, new Vector2(0.7f, 0.7f), state);
            }
        }
Exemple #7
0
        public void WasShot()
        {
            var rand = new Random();

            IsExpired = true;
            PlayerStatus.AddPoints(PointValue);
            PlayerStatus.IncreaseMultiplier();
            var hue1   = rand.NextFloat(0, 6);
            var hue2   = (hue1 + rand.NextFloat(0, 2)) % 6f;
            var color1 = ColorUtil.HSVToColor(hue1, 0.5f, 1);
            var color2 = ColorUtil.HSVToColor(hue2, 0.5f, 1);

            Sound.Explosion.Play(0.5f, rand.NextFloat(-0.2f, 0.2f), 0);
            for (var i = 0; i < 120; i++)
            {
                float speed         = 18f * (1f - 1 / rand.NextFloat(1f, 10f));
                var   state         = new ParticleState(rand.NextVector2(speed, speed), ParticleType.Enemy);
                var   particleColor = Color.Lerp(color1, color2, rand.NextFloat(0, 1));
                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, particleColor, 180, new Vector2(0.7f, 0.7f), state);
            }
        }
        public void Kill()
        {
            PlayerStatus.RemoveLife();
            framesUntilRespawn = PlayerStatus.IsGameOver ? 300 : 120;

            Color explosionColor = new Color(0.8f, 0.8f, 0.4f);                 // yellow

            for (int i = 0; i < 1200; i++)
            {
                float speed = 18f * (1f - 1 / rand.NextFloat(1f, 10f));
                Color color = Color.Lerp(Color.White, explosionColor, rand.NextFloat(0, 1));
                var   state = new ParticleState()
                {
                    Velocity         = rand.NextVector2(speed, speed),
                    Type             = ParticleType.None,
                    LengthMultiplier = 1
                };

                NeonShooterGame.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
            }
        }
Exemple #9
0
        public void Kill()
        {
            EntityManager.Reset();
            EnemySpawner.Reset();
            //framesUntilRespawn = 60;
            PlayerStatus.RemoveLife();
            PlayerStatus.ResetMultiplier();
            if (PlayerStatus.Lives == 0)
            {
                PlayerStatus.GameOver();
                GameManager.PauseGame(300, true);
            }
            framesUntilRespawn = PlayerStatus.IsGameOver ? 300 : 120;
            var yellow = new Color(0.8f, 0.8f, 0.4f);

            for (var i = 0; i < 1200; i++)
            {
                var speed         = 18f * (1f - 1 / rand.NextFloat(1f, 10f));
                var particleColor = Color.Lerp(Color.White, yellow, rand.NextFloat(0, 1));
                var state         = new ParticleState(rand.NextVector2(speed, speed), ParticleType.None);

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, particleColor, 60, new Vector2(0.7f, 0.7f), state);
            }
        }