Ejemplo 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();
        }
Ejemplo 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++;
            }
        }
Ejemplo n.º 3
0
        public AsteroidsForm()
        {
            InitializeComponent();

            ExplodingAsteroid.Hide();
            NukeCloud.Hide();
            RocketPB.Hide();
            RedGift.Hide();
            LaserPB.Hide();
            RocketGift.Hide();
            DashboardGiftLabel.Hide();
            GameOver.Hide();

            LaserPB.BringToFront();

            Bomb.X       = 200;
            Bomb.Y       = -60;
            Bomb.Life    = BombLife;
            Rocket.Count = 10;
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Logic implement Destroying a Gift
        /// Hide unnecessary pictures
        /// Show destroing animation, reset the constants and аdding rockets.
        /// </summary>
        private void DestroyGift()
        {
            RocketPB.Hide();
            RedGift.Hide();

            score += 4;
            ScoreCounter();
            Rocket.Count++;
            RocketCount(Rocket.Count);

            Gift.IsRocketComming = false;
            Rocket.IsFired       = false;
            isGiftVisible        = false;
            Gift.IsExploding     = false;

            RocketGift.Left = RedGift.Left + RedGift.Width / 2 - RocketGift.Width / 2;
            RocketGift.Top  = RedGift.Top + RedGift.Height / 2;
            RocketGift.Show();

            DashboardGiftLabel.Show();
            Gift.ContentShowTyme = GiftContentShowTime;
        }