示例#1
0
        /// <summary>
        /// The logic implement movement of destroing asteroids and calculating using a timer
        /// This method chek if lives == 0 -> Game Over
        /// </summary>
        private void AnimationTimer_Tick(object sender, EventArgs e)
        {
            if (destroyedImageCounter > 1 && destroyed)
            {
                ExplodingAsteroid.Hide();
                destroyed             = false;
                destroyedImageCounter = 0;
            }
            else if (destroyed)
            {
                destroyedImageCounter++;
            }

            if (nukeCity && !destroyed)
            {
                if (nukeCloudCounter == 0)
                {
                    MissCounter();

                    if (missCount == 0)
                    {
                        AsteroidPositionTimer.Stop();
                        StartGame.IsStarted = false;

                        BombPB.Hide();
                        RedGift.Hide();
                        NukeCloud.Hide();
                        ExplodingAsteroid.Hide();
                        RocketPB.Hide();
                        RocketGift.Hide();
                        Lives.Hide();

                        GameOver.Show();
                    }

                    nukeCity           = true;
                    NukeCloud.Location = new Point(Bomb.X, Bomb.Y);
                    NukeCloud.Show();
                    PlaySound.PlayExplodeSound();

                    Bomb.Life = BombLife;
                    SpawnNewBomb();
                }
                else if (nukeCloudCounter > 10)
                {
                    NukeCloud.Hide();
                    AnimationTimer.Stop();
                    nukeCity = false;
                }

                nukeCloudCounter++;
            }
        }