Exemplo n.º 1
0
        private void Restart_Click(object sender, EventArgs e)
        {
            AsteroidPositionTimer.Stop();

            StartGame.IsStarted  = false;
            destroyed            = false;
            Bomb.IsExploding     = false;
            Gift.IsRocketComming = false;
            Rocket.IsFired       = false;
            nukeCity             = false;

            Bomb.Life = 3;
            Bomb.Y    = -30;
            Gift.Y    = -30;

            BombPB.Hide();
            RocketPB.Hide();
            LaserPB.Hide();
            RedGift.Hide();
            GameOver.Hide();
            DashboardGiftLabel.Hide();

            Rocket.Count = 10;
            score        = -1;
            missCount    = 6;

            RocketCount(Rocket.Count);
            ScoreCounter();
            MissCounter();
            Lives.Show();
        }
Exemplo n.º 2
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++;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Logic implement Destroying a Bomb
        /// Hide unnecessary pictures
        /// Show destroing animation, reset the constants and spawn new bomb.
        /// </summary>
        private void DestroyBomb()
        {
            PlaySound.PlayExplodeSound();
            BombPB.Hide();
            RocketPB.Hide();
            LaserPB.Hide();

            ExplodingAsteroid.Left = BombPB.Left - 10;
            ExplodingAsteroid.Top  = BombPB.Top - 20;
            ExplodingAsteroid.Show();

            destroyed        = true;
            nukeCity         = false;
            Bomb.IsExploding = false;
            Rocket.IsFired   = false;
            Bomb.Life        = 3;

            SpawnNewBomb();
            ScoreCounter();
            AnimationTimer.Start();
        }