public void Load(Action <UM_AchievementsLoadResult> callback) { Dictionary <string, ISN_GKAchievement> achievementsDict = new Dictionary <string, ISN_GKAchievement>(); foreach (var achievement in ISN_GKAchievement.GetGameAchievements()) { achievementsDict.Add(achievement.Identifier, achievement); } ISN_GKAchievement.LoadAchievements((result) => { UM_AchievementsLoadResult loadResult; if (result.IsSucceeded) { foreach (var achievement in result.Achievements) { if (achievementsDict.ContainsKey(achievement.Identifier)) { string name = achievementsDict[achievement.Identifier].Name; achievement.Name = name; achievementsDict[achievement.Identifier] = achievement; } else { achievementsDict.Add(achievement.Identifier, achievement); } } var achievements = new List <UM_iAchievement>(); foreach (var pair in achievementsDict) { var achievement = pair.Value; var iosAchievement = new UM_IOSAchievement(achievement); SetAchievementCahce(iosAchievement); achievements.Add(iosAchievement); } loadResult = new UM_AchievementsLoadResult(achievements); } else { loadResult = new UM_AchievementsLoadResult(result.Error); } callback.Invoke(loadResult); }); }
public void Load(Action <UM_AchievementsLoadResult> callback) { UM_EditorAPIEmulator.WaitForNetwork(() => { UM_AchievementsLoadResult loadResult; var achievements = new List <UM_iAchievement>(); foreach (var achievement in ISN_GKAchievement.GetGameAchievements()) { if (UM_EditorAPIEmulator.HasKey(achievement.Identifier)) { achievement.PercentComplete = UM_EditorAPIEmulator.GetFloat(achievement.Identifier); } var iosAchievement = new UM_IOSAchievement(achievement); SetAchievementCahce(iosAchievement); achievements.Add(iosAchievement); } loadResult = new UM_AchievementsLoadResult(achievements); callback.Invoke(loadResult); }); }
public void Increment(string achievementId, int numSteps, Action <SA_Result> callback) { //We need to caclulate PercentComplete. //Let's see if we have an achivement info already UM_iAchievement achievement = GetAchievementById(achievementId); if (achievement != null) { Increment(achievement, numSteps, callback); } else { Load((result) => { if (result.IsSucceeded) { //It should be cached at this point already achievement = GetAchievementById(achievementId); if (achievement == null) { ISN_GKAchievement iSN_achievement = new ISN_GKAchievement(achievementId); var iosAchievement = new UM_IOSAchievement(iSN_achievement); SetAchievementCahce(iosAchievement); achievement = iosAchievement; } Increment(achievement, numSteps, callback); } else { var error = new SA_Error(100, "Wasn't able to load achievement with id: " + achievementId); callback.Invoke(new SA_Result(error)); } }); } }