public void Play_Start_Click(object sender, EventArgs e) // Function switches on a game { LevelUpGif.BringToFront(); if (firstPlane) { Heart1.Visible = true; Heart2.Visible = true; Heart3.Visible = true; } else if (secondPlane) { this.Controls.Remove(Heart1); Heart1.Dispose(); Heart2.Visible = true; Heart3.Visible = true; } else if (thirdPlane) { this.Controls.Remove(Heart1); Heart1.Dispose(); this.Controls.Remove(Heart2); Heart2.Dispose(); Heart3.Visible = true; } if (isstarted) { if (paused) { StartTimers(); Menu_Off(); } } if (!isstarted) { isstarted = true; Menu_Off(); Player.Visible = true; Change_Off.Visible = false; PointsLabel.Visible = true; StarsMoveTimer.Start(); for (int i = 0; i < stars.Length; i++) { stars[i].Visible = true; } enemyMoveTimer.Start(); } }
public void EnemyBulletsCollision() { for (int i = 0; i < enemies.Count; i++) { if (thirdPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds)) { //destruction of the third heart //gameover enemies[i].EnemyBullet.death(); this.Controls.Remove(Heart3); Heart3.Dispose(); gameover(); } else if (secondPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds)) { HeatCount++; Player.Location = new Point(313, 570); enemies[i].EnemyBullet.death(); if (HeatCount == 1) { //destruction of the second heart this.Controls.Remove(Heart2); Heart2.Dispose(); } else if (HeatCount == HP) { //destruction of the Third heart //gameover this.Controls.Remove(Heart3); Heart3.Dispose(); gameover(); } } else if (firstPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds)) { HeatCount++; Player.Location = new Point(313, 570); enemies[i].EnemyBullet.death(); if (HeatCount == 1) { //destruction of the first heart this.Controls.Remove(Heart1); Heart1.Dispose(); } else if (HeatCount == 2) { //destruction of the second heart this.Controls.Remove(Heart2); Heart2.Dispose(); } else if (HeatCount == HP) { //destruction of the third heart //gameover this.Controls.Remove(Heart3); Heart3.Dispose(); gameover(); } } } }