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
        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;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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();
                }
            }
        }