void Load() { TextAsset AchievementFile = Resources.Load <TextAsset>("Achievements"); string[] achievementsstring = AchievementFile.text.Split(new char[] { '\n' }); for (int i = 1; i < achievementsstring.Length - 1; ++i) { string[] tempString = achievementsstring[i].Split(new char[] { ',' }); if (tempString[0] == "") { break; } bool tempActive = false; bool.TryParse(tempString[2], out tempActive); int temp = 0; int.TryParse(tempString[3], out temp); Achievements newAchievement = new Achievements(tempString[0], tempString[1], tempActive, temp); for (int j = 4; j < tempString.Length; j += 3) { if (tempString[j] != "") { AchievementsProperties ChildProperty = new AchievementsProperties(); float tempCount = 0.0f; float.TryParse(tempString[j + 2], out tempCount); ChildProperty.PropertyName = tempString[j]; ChildProperty.PropertyDetails = tempString[j + 1]; ChildProperty.CompletionCounter = tempCount; newAchievement.AddProperty(ChildProperty); PropertiesList.Add(ChildProperty.PropertyName, ChildProperty); } } AchievementsList.Add(newAchievement.AchievementName, newAchievement); } }
/* Load Achievements */ public void LoadAchievements(Dictionary <string, Achievements> _achievement) { int TotalAchievements = PlayerPrefs.GetInt("NumStoredAchievements"); if (TotalAchievements > 0) { for (int i = 0; i < TotalAchievements; ++i) { string[] tempitem = PlayerPrefs.GetString("achievement " + i).Split(new char[] { ',' }); bool tempb; bool.TryParse(tempitem[2], out tempb); bool tempb2; bool.TryParse(tempitem[3], out tempb2); int temp; int.TryParse(tempitem[4], out temp); Achievements newAch = new Achievements(tempitem[0], tempitem[1], tempb, tempb2, temp); if (tempitem[5] != "") { for (int j = 5; j < tempitem.Length; ++j) { if (tempitem[j] == "") { break; } AchievementsProperties achprop = GameObject.FindGameObjectWithTag("GameScript").GetComponent <AchievementsManager>().GetProperty(tempitem[j]); newAch.AddProperty(achprop); } } _achievement.Add(newAch.AchievementName, newAch); } } }
/* Load Properties */ public void LoadProperties(Dictionary <string, AchievementsProperties> _properties) { int TotalProperties = PlayerPrefs.GetInt("NumStoredProperties"); if (TotalProperties > 0) { for (int i = 0; i < TotalProperties; ++i) { string[] tempitem = PlayerPrefs.GetString("property " + i).Split(new char[] { ',' }); float temp2 = 0.0f; float.TryParse(tempitem[2], out temp2); float temp3 = 0.0f; float.TryParse(tempitem[3], out temp3); bool tempb; bool.TryParse(tempitem[4], out tempb); AchievementsProperties newProp = new AchievementsProperties(tempitem[0], tempitem[1], temp2, temp3, tempb); _properties.Add(newProp.PropertyName, newProp); } } }
public void AddProperty(AchievementsProperties _property) { _property.PropertyName = _property.PropertyName.ToUpper(); PropertiesList.Add(_property); }