// Loads the saved achievements file and updates the array with its content. public static void LoadSavedAchievements() { DeterminePath(); SerializedAchievementManager serializedAchievementManager = (SerializedAchievementManager)SaveLoadManager.Load(typeof(SerializedAchievementManager), _saveFileName + _saveFileExtension, _saveFolderName); ExtractSerializedMMAchievementManager(serializedAchievementManager); }
// Saves the achievements current status to a file on disk public static void SaveAchievements() { DeterminePath(); SerializedAchievementManager serializedAchievementManager = new SerializedAchievementManager(); FillSerializedAchievementManager(serializedAchievementManager); SaveLoadManager.Save(serializedAchievementManager, _saveFileName + _saveFileExtension, _saveFolderName); }
// Serializes the contents of the achievements array to a serialized, ready to save object public static void FillSerializedAchievementManager(SerializedAchievementManager serializedAchievements) { serializedAchievements.Achievements = new SerializedAchievement[_achievements.Count]; for (int i = 0; i < _achievements.Count(); i++) { SerializedAchievement newAchievement = new SerializedAchievement(_achievements[i].AchievementID, _achievements[i].UnlockedStatus, _achievements[i].ProgressCurrent); serializedAchievements.Achievements[i] = newAchievement; } }
// Extracts the serialized achievements into our achievements array if the achievements ID match. public static void ExtractSerializedMMAchievementManager(SerializedAchievementManager serializedAchievements) { if (serializedAchievements == null) { return; } for (int i = 0; i < _achievements.Count(); i++) { for (int j = 0; j < serializedAchievements.Achievements.Length; j++) { if (_achievements[i].AchievementID == serializedAchievements.Achievements[j].AchievementID) { _achievements[i].UnlockedStatus = serializedAchievements.Achievements[j].UnlockedStatus; _achievements[i].ProgressCurrent = serializedAchievements.Achievements[j].ProgressCurrent; } } } }