private void exit_Click(object sender, EventArgs e) { DialogResult userSelected = MessageBox.Show("Are You Sure", "Warning", MessageBoxButtons.YesNo); if (userSelected == DialogResult.Yes) { Main_Menu mainmenu = new Main_Menu(); mainmenu.Owner = this; mainmenu.Show(); this.Close(); this.Dispose(); } }
private void pengecekanLife() { if (life == 3) { listofheart.Image = Properties.Resources._3_life; this.Refresh(); } else if (life == 2) { listofheart.Image = Properties.Resources._2life; this.Refresh(); } else if (life == 1) { listofheart.Image = Properties.Resources._1life; this.Refresh(); } else if (life == 0) { listofheart.Hide(); timerEnemy1Generator.Enabled = false; timerEnemy2Generator.Enabled = false; timerLaserMove.Enabled = false; timerGame.Enabled = false; this.Refresh(); DialogResult userSelection = MessageBox.Show("Life Habis Kamu Kalah!", "Game Over!", MessageBoxButtons.OK); if (userSelection == DialogResult.OK) { Main_Menu mainmenu = new Main_Menu(); mainmenu.Owner = this; mainmenu.Show(); this.Close(); this.Dispose(); } } }
private void pengecekanLife() { if (life == 3) { listofheart.Image = Properties.Resources._3_life; this.Refresh(); } else if (life == 2) { listofheart.Image = Properties.Resources._2life; this.Refresh(); } else if (life == 1) { listofheart.Image = Properties.Resources._1life; this.Refresh(); } else if (life == 0) { listofheart.Hide(); timerEnemy1Generator.Enabled = false; timerEnemy2Generator.Enabled = false; timerLaserMove.Enabled = false; timerGame.Enabled = false; this.Refresh(); DialogResult userSelection = MessageBox.Show("You have survived for : " + minutes + " Minutes " + " and " + seconds + " Seconds " + "\nBack to mode select", "\t" + "Game Over", MessageBoxButtons.OK); List <int> listOfHighScore = new List <int>(); StreamReader sr = new StreamReader(Application.StartupPath + "/HighscoreSurvival.txt"); //membaca line string line = sr.ReadLine(); //baca sampe akhir while (line != null) { //masukan line ke dalam list listOfHighScore.Add(int.Parse(line)); //lanjut ke line berikutnya line = sr.ReadLine(); } sr.Close(); int totalSecond = 60 * minutes + seconds; listOfHighScore.Add(totalSecond); listOfHighScore.Sort(); listOfHighScore.Reverse(); //menulis score ke dalam txt files StreamWriter sw; sw = new StreamWriter(Application.StartupPath + "/HighscoreSurvival.txt"); for (int i = 0; i < listOfHighScore.Count - 1; i++) { sw.WriteLine(listOfHighScore[i].ToString()); } sw.Close(); if (userSelection == DialogResult.OK) { Main_Menu mainmenu = new Main_Menu(); mainmenu.Owner = this; mainmenu.Show(); this.Close(); this.Dispose(); } } }