Esempio n. 1
0
        /// <summary>
        /// Handles death for the ship
        /// </summary>
        public void Kill()
        {
            // Remove a life
            PlayerStatus.RemoveLife();

            // Reset the position
            Position = new Vector2(GameBase.ScreenSize.X / 2, GameBase.ScreenSize.Y - 10);

            // Set the frames until respawn as 120 if the game is not over, and 300 if the game is over
            framesUntilRespawn = PlayerStatus.IsGameOver ? 300 : 120;

            // Create a yellow explosion colour
            Color explosionColor = new Color(0.8f, 0.8f, 0.4f);

            // Create death particles
            for (int i = 0; i < 1200; i++)
            {
                // Define the particle speed and colour
                float speed = 18f * (1f - 1 / rand.NextFloat(1f, 10f));
                Color color = Color.Lerp(Color.White, explosionColor, rand.NextFloat(0, 1));

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

                // Create the individual particle
                GameBase.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
            }
        }
Esempio n. 2
0
        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
                };

                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190, 1.5f, state);
            }
        }
Esempio n. 3
0
 public void Kill()
 {
     PlayerStatus.RemoveLife();
     framesUntilRespawn = PlayerStatus.IsGameOver ? 300 : 120;
 }