/// <summary> /// We enter this method when we click on the gift icon /// Check rigth or left button on the mouse is click and make some logic /// </summary> private void RedGift_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (Rocket.Count > 0 && !Rocket.IsFired && StartGame.IsStarted) { int count = Rocket.Count--; RocketCount(count - 1); ScoreCounter(); PlaySound.PlayMouseSound(e.Button); Rocket.Fire(RocketPB, Height, RedGift.Left + RedGift.Width / 4); } } else { if (StartGame.IsStarted) { PlaySound.PlayMouseSound(e.Button); Laser.LightUp(LaserPB, Gift.X, RedGift, true); DestroyGift(); } } }
/// <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(); } } }