public static AGSRequestAchievementsForPlayerResponse GetBlankResponseWithError(string error, string playerId = "", int userData = 0) { AGSRequestAchievementsForPlayerResponse response = new AGSRequestAchievementsForPlayerResponse (); response.error = error; response.playerId = playerId; response.userData = userData; response.achievements = new List<AGSAchievement>(); return response; }
public static new AGSRequestAchievementsForPlayerResponse FromJSON(string json) { try { AGSRequestAchievementsForPlayerResponse response = new AGSRequestAchievementsForPlayerResponse (); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString () : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString ()) : 0; response.achievements = new List<AGSAchievement>(); if (hashtable.ContainsKey("achievements")) { foreach (Hashtable achievementHashtable in hashtable["achievements"] as ArrayList) { response.achievements.Add(AGSAchievement.fromHashtable(achievementHashtable)); } } response.playerId = hashtable.ContainsKey ("playerId") ? hashtable ["playerId"].ToString () : ""; return response; } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return GetBlankResponseWithError(JSON_PARSE_ERROR); } }
public new static AGSRequestAchievementsForPlayerResponse FromJSON(string json) { try { AGSRequestAchievementsForPlayerResponse response = new AGSRequestAchievementsForPlayerResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.achievements = new List <AGSAchievement>(); if (hashtable.ContainsKey("achievements")) { foreach (Hashtable achievementHashtable in hashtable["achievements"] as ArrayList) { response.achievements.Add(AGSAchievement.fromHashtable(achievementHashtable)); } } response.playerId = hashtable.ContainsKey("playerId") ? hashtable ["playerId"].ToString() : ""; return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
private void OnRequestAchievementsForFriendCompleted(AGSRequestAchievementsForPlayerResponse response) { achievementsForFriend [response.playerId] = new List<string> (); if (response.IsError ()) { achievementsForFriend [response.playerId].Add(string.Format("Error getting achievements for player: {0}", response.error)); } else { foreach(AGSAchievement achievement in response.achievements) { achievementsForFriend [response.playerId].Add(achievement.ToString()); } } }