// ADD THE CURRENT SCORE TO TOP SCORES \\ private void AddNewScore() { TopScore currentScore = new TopScore(score, "anonymous"); HighScore highScr = new HighScore(currentScore); highScr.ShowDialog(); }
// ADDS TOP SCORE TO LIST, OPENS THE HIGHEST SCORES WINDOW \\ private void HighScore_FormClosed(object sender, FormClosedEventArgs e) { // REMOVES LOWEST SCORE IF NECESSARY \\ if (TopScore.topScores.Count >= Form1.MAX_TOP_SCORES) { int lowest = TopScore.topScores.Min(i => i.Score); TopScore lowestScore = TopScore.topScores.Find(i => i.Score == lowest); TopScore.topScores.Remove(lowestScore); } // ADDS NEW HIGH SCORE \\ TopScore.topScores.Add(Current); HighestScores highestscrs = new HighestScores(); highestscrs.ShowDialog(); }
// READS IN THE TOP SCORES FROM FILE \\ private void ReadTopScores() { try { if (File.Exists(SCORE_FILE)) { using (StreamReader read = new StreamReader(SCORE_FILE)) { while (!read.EndOfStream) { string[] scoreInfo = read.ReadLine().Split('|'); TopScore current = new TopScore(int.Parse(scoreInfo[SCORE]), scoreInfo[NAME]); TopScore.topScores.Add(current); } } } } catch (Exception err) { MessageBox.Show(err.Message); } }
public HighScore(TopScore _ts) { InitializeComponent(); Current = _ts; }