public static EnhancedScoreboard Init() { EnhancedScoreboard instance = new EnhancedScoreboard(); try { Scoreboard2 highScoreData = Scoreboard2.Load(); instance.Scores = highScoreData.Scores; instance.EnhancedScores = highScoreData.Scores.Select(parent => new EnhancedScoreEntry(parent)).ToList(); } catch (Exception ex) { Utilities.Logger.Log($"(Error) Failed to load HighScores data [{ex}]"); instance = new EnhancedScoreboard(); } return(instance); }
public static EnhancedScoreboard Load() { EnhancedScoreboard instance = new EnhancedScoreboard(); try { using (Stream stream = File.OpenRead(DataManager.SavePath("HighScores.dat"))) { var inst = (((IFormatter) new BinaryFormatter()).Deserialize(stream) as Scoreboard); stream.Close(); instance.Scores = inst.Scores; instance.EnhancedScores = inst.Scores.Select(parent => new EnhancedScoreEntry(parent)).ToList(); } } catch (Exception ex) { Utilities.Logger.Log($"(Error) Failed to load HighScores.dat [{ex}]"); instance = new EnhancedScoreboard(); } return(instance); }