/// <summary> /// Create Highscores class, will basically try to load highscore list, /// if that fails we generate a standard highscore list! /// </summary> static Highscores() { // Init highscores highscores = new HighscoreHelper[NumOfHighscores]; // Get player name from windows computer/user name if not set yet. if (String.IsNullOrEmpty(GameSettings.Default.PlayerName)) { // And save it back GameSettings.Default.PlayerName = WindowsHelper.GetDefaultPlayerName(); } // if (String.IsNullOrEmpty) if (ReadHighscoresFromSettings() == false) { // Generate default lists highscores[9] = new HighscoreHelper("Kai", 90000); highscores[8] = new HighscoreHelper("Viper", 85000); highscores[7] = new HighscoreHelper("Netfreak", 80000); highscores[6] = new HighscoreHelper("Darky", 75000); highscores[5] = new HighscoreHelper("Waii", 70000); highscores[4] = new HighscoreHelper("Judge", 65000); highscores[3] = new HighscoreHelper("exDreamBoy", 60000); highscores[2] = new HighscoreHelper("Master_L", 55000); highscores[1] = new HighscoreHelper("Freshman", 50000); highscores[0] = new HighscoreHelper("abi", 45000); WriteHighscoresToSettings(); } // if (ReadHighscoresFromSettings) }
/// <summary> /// Read highscores from settings /// </summary> /// <returns>True if reading succeeded, false otherwise.</returns> private static bool ReadHighscoresFromSettings() { if (String.IsNullOrEmpty(GameSettings.Default.Highscores)) return false; string highscoreString = GameSettings.Default.Highscores; string[] allHighscores = highscoreString.Split(new char[] { ',' }); for (int num = 0; num < NumOfHighscores; num++) { string[] oneHighscore = allHighscores[num].Split(new char[] { ':' }); highscores[num] = new HighscoreHelper( oneHighscore[0], Convert.ToInt32(oneHighscore[1])); } // for (num) return true; }