public static AGSRequestScoresResponse FromJSON(string json) { try { AGSRequestScoresResponse response = new AGSRequestScoresResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.leaderboardId = hashtable.ContainsKey("leaderboardId") ? hashtable ["leaderboardId"].ToString() : ""; if (hashtable.ContainsKey("leaderboard")) { response.leaderboard = AGSLeaderboard.fromHashtable(hashtable ["leaderboard"] as Hashtable); } else { response.leaderboard = AGSLeaderboard.GetBlankLeaderboard(); } response.scores = new List <AGSScore> (); if (hashtable.Contains("scores")) { foreach (Hashtable scoreHashtable in hashtable["scores"] as ArrayList) { response.scores.Add(AGSScore.fromHashtable(scoreHashtable)); } } response.scope = (LeaderboardScope)Enum.Parse(typeof(LeaderboardScope), hashtable["scope"].ToString()); return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
/// <summary> /// callback method for native code to communicate events back to unity /// </summary> public static void RequestLeaderboardsSucceeded(string json) { if (RequestLeaderboardsSucceededEvent != null) { var leaderboards = new List <AGSLeaderboard>(); var arrayList = json.arrayListFromJson(); foreach (Hashtable ht in arrayList) { leaderboards.Add(AGSLeaderboard.fromHashtable(ht)); } RequestLeaderboardsSucceededEvent(leaderboards); } }
/// <summary> /// callback method for native code to communicate events back to unity /// </summary> public static void RequestPercentileRanksSucceeded(string json) { if (RequestPercentileRanksSucceededEvent != null) { var ht = json.hashtableFromJson(); AGSLeaderboard leaderboard = AGSLeaderboard.fromHashtable(ht["leaderboard"] as Hashtable); var arrayList = (ht["percentiles"] as ArrayList); List <AGSLeaderboardPercentile> percentiles = new List <AGSLeaderboardPercentile>(); foreach (Hashtable pht in arrayList) { percentiles.Add(AGSLeaderboardPercentile.fromHashTable(pht)); } int localPlayerIndex = int.Parse(ht["localPlayerIndex"].ToString()); RequestPercentileRanksSucceededEvent(leaderboard, percentiles, localPlayerIndex); } }
public static AGSRequestLeaderboardsResponse FromJSON(string json) { try { AGSRequestLeaderboardsResponse response = new AGSRequestLeaderboardsResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.leaderboards = new List <AGSLeaderboard>(); if (hashtable.ContainsKey("leaderboards")) { foreach (Hashtable leaderboardHashtable in hashtable["leaderboards"] as ArrayList) { response.leaderboards.Add(AGSLeaderboard.fromHashtable(leaderboardHashtable)); } } return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }