public void GameOver() { timer1.Stop(); exitGameBtn = false; mainSound.Stop(); gameOverS.Play(); EndGame form = new EndGame(); form.ShowDialog(); player = new Player(form.NameP, ballCollection.Score); playersScore.Add(player); writeFile(); if (form.End == 0) { newGame(); sw.Flush(); } else if (form.End == 1) { this.Close(); sw.Close(); } }
public FallScores() { InitializeComponent(); String filePath = System.IO.Path.GetFullPath("FlappyScore.txt"); StreamReader sr = new StreamReader(filePath); String s = ""; while ((s = sr.ReadLine()) != null) { string[] strings = { " ", "0" }; Player p = new Player(strings[0], int.Parse(strings[1])); if (s.Contains(',')) { strings = s.Split(','); } if (strings.Count() == 2) { p = new Player(strings[0], int.Parse(strings[1])); } lstScores.Items.Add(p); lstScores.Items.Add(""); } sr.Close(); }
public void endGame() { exitGameBtn = false; timer1.Stop(); mainSound.Stop(); EndGame form = new EndGame(); form.ShowDialog(); player = new Player(form.NameP, Score); playersScore.Add(player); writeFile(); if (form.End == 0) { Score = 0; runGame(); } else if (form.End == 1) { this.Close(); sw.Close(); } }