示例#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();
        }
示例#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++;
            }
        }
示例#3
0
        /// <summary>
        /// The logic implement movement of gifts and asteroids and calculating using a timer
        /// </summary>
        private void AsteroidPositionTimer_Tick(object sender, EventArgs e)
        {
            /// <summary>
            /// Stop timer, when the game is not start with start buton
            /// </summary>
            if (!StartGame.GameIsStarted())
            {
                AsteroidPositionTimer.Stop();
            }

            /// <summary>
            /// If an asteroid and a gift appear at the same place, new coordinates are calculated
            /// </summary>
            if (Gift.ContentShowTyme > 0)
            {
                Gift.ContentShowTyme--;

                if (Gift.ContentShowTyme == 0)
                {
                    RocketGift.Hide();
                    DashboardGiftLabel.Hide();
                }
            }

            /// <summary>
            /// Look Rocket.cs class
            /// </summary>
            if (Rocket.IsFired)
            {
                Rocket.Move(RocketPB);
            }

            /// <summary>
            /// Chek count laser hits on asteroid and when asteroid is dead, hide Laser from the screen.
            /// </summary>
            if (Laser.TimeCounter > 0)
            {
                Laser.TimeCounter--;
            }
            else
            {
                LaserPB.Hide();
            }

            /// <summary>
            /// If asteroid is hiting by laser or rocket, we destroying him.
            /// </summary>
            if (Bomb.IsExploding)
            {
                DestroyBomb();
            }

            /// <summary>
            /// Set new coordinates on asteroid and show bomb.
            /// </summary>
            Bomb.Y         += 7;
            BombPB.Location = new Point(Bomb.X, Bomb.Y);
            BombPB.Show();

            /// <summary>
            /// Chek coordinates and explode asteroid random on screen.
            /// </summary>
            if (Bomb.Y >= rnd.Next(380, 470) && !Bomb.IsExploding)
            {
                nukeCity         = true;
                nukeCloudCounter = 0;
                AnimationTimer.Start();
            }

            /// <summary>
            /// If gift is hiting by laser or rocket, we destroying him.
            /// </summary>
            if (Gift.IsExploding)
            {
                DestroyGift();
            }

            /// <summary>
            /// Logic encompasses the movement and the disappearance of the gift when it's not hiting.
            /// </summary>
            if (isGiftVisible)
            {
                if (Gift.Y >= 700)
                {
                    isGiftVisible = false;
                    RedGift.Hide();
                }
                else
                {
                    Gift.Y          += 5;
                    RedGift.Location = new Point(Gift.X, Gift.Y);
                }
            }
            else
            {
                isGiftVisible = rnd.Next(0, 50) == 1;

                if (isGiftVisible)
                {
                    SpawnGift();
                }
            }
        }
示例#4
0
 private void StartGame_Click(object sender, EventArgs e)
 {
     StartGame.IsStarted = true;
     AsteroidPositionTimer.Start();
 }
示例#5
0
 private void PauseGame_Click(object sender, EventArgs e)
 {
     AsteroidPositionTimer.Stop();
     StartGame.IsStarted = false;
     NukeCloud.Hide();
 }