public static void WriteHighScore(List_highscore Players) { Stream s = File.Open(filename, FileMode.Create); BinaryFormatter binary = new BinaryFormatter(); binary.Serialize(s, Players); s.Close(); }
public static void WriteNewScore(Player player, int kind) { List_highscore ls = HighScoreGame.ReadHighScore(); if (kind == 1) { ListPlayer p = ls.player_easy; p.player[9] = player; ls.player_easy.sort(); WriteHighScore(new List_highscore(p, ls.player_mid, ls.player_hard)); } else if (kind == 2) { ListPlayer p = ls.player_mid; p.player[9] = player; ls.player_mid.sort(); WriteHighScore(new List_highscore(ls.player_easy, p, ls.player_hard)); } else { ListPlayer p = ls.player_hard; p.player[9] = player; ls.player_hard.sort(); WriteHighScore(new List_highscore(ls.player_easy, ls.player_mid, p)); } }
public static List_highscore ReadHighScore() { if (!File.Exists(filename)) { WriteDefault(); } Stream s = File.Open(filename, FileMode.Open); BinaryFormatter binary = new BinaryFormatter(); List_highscore hs = (List_highscore)binary.Deserialize(s); s.Close(); return(hs); }
public List_highscore(List_highscore a) { this.player_easy = a.player_easy; this.player_mid = a.player_mid; this.player_hard = a.player_hard; }