public Game() { this.gameClock = new GameClock(); this.Services = new GameServiceContainer(); this.Settings = GameSettings.LoadOrCreate(); this.HighScores = HighScores.LoadOrCreate(); this.Random = new Random(); this.Board = new Board(this); this.Board.GameOver += GameOver; this.Window = new GameForm(this); this.Window.Idle += GameWindow_Idle; this.GraphicsDeviceService = new GameGraphicsDeviceService(this); }
public static HighScores LoadOrCreate() { HighScores highScores = new HighScores(); if (File.Exists("highscores.xml")) { try { XmlSerializer serializer = new XmlSerializer(typeof(List <HighScore>)); TextReader reader = new StreamReader("highscores.xml"); List <HighScore> highScoreList = (List <HighScore>)serializer.Deserialize(reader); reader.Close(); highScores.highScores = highScoreList; } catch (InvalidOperationException e) { } } return(highScores); }