示例#1
0
 public new static AGSRequestPercentilesForPlayerResponse FromJSON(string json)
 {
     try {
         AGSRequestPercentilesForPlayerResponse response = new AGSRequestPercentilesForPlayerResponse();
         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.percentiles = new List <AGSLeaderboardPercentile> ();
         if (hashtable.Contains("percentiles"))
         {
             foreach (Hashtable percentileHashtable in hashtable["percentiles"] as ArrayList)
             {
                 response.percentiles.Add(AGSLeaderboardPercentile.fromHashTable(percentileHashtable));
             }
         }
         response.userIndex = hashtable.ContainsKey("userIndex") ? int.Parse(hashtable ["userIndex"].ToString()) : -1;
         response.scope     = (LeaderboardScope)Enum.Parse(typeof(LeaderboardScope), hashtable["scope"].ToString());
         response.playerId  = hashtable.ContainsKey("playerId") ? hashtable ["playerId"].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 RequestPercentileRanksForPlayerComplete(string json)
 {
     if (RequestPercentileRanksForPlayerCompleted != null)
     {
         RequestPercentileRanksForPlayerCompleted(AGSRequestPercentilesForPlayerResponse.FromJSON(json));
     }
 }
 public static new AGSRequestPercentilesForPlayerResponse FromJSON(string json)
 {
     try {
         AGSRequestPercentilesForPlayerResponse response = new AGSRequestPercentilesForPlayerResponse ();
         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.percentiles = new List<AGSLeaderboardPercentile> ();
         if (hashtable.Contains ("percentiles")) {
             foreach (Hashtable percentileHashtable in hashtable ["percentiles"] as ArrayList) {
                 response.percentiles.Add(AGSLeaderboardPercentile.fromHashTable(percentileHashtable));
             }
         }
         response.userIndex = hashtable.ContainsKey ("userIndex") ? int.Parse (hashtable ["userIndex"].ToString ()) : -1;
         response.scope = (LeaderboardScope) Enum.Parse(typeof(LeaderboardScope), hashtable["scope"].ToString());
         response.playerId = hashtable.ContainsKey ("playerId") ? hashtable ["playerId"].ToString () : "";
         return response;
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return GetBlankResponseWithError(JSON_PARSE_ERROR);
     }
 }
    /// <summary>
    /// ANDROID ONLY
    /// Request percentile ranks for a player.
    /// </summary>
    /// <remarks>
    /// RequestPercentileRanksForPlayerCompleted will be called if the event is registered.
    /// </remarks>
    /// <param name="leaderboardId">the id of the leaderboard for the score request.</param>
    /// <param name="playerId">The player identifier for the request.</para>
    /// <param name="scope">enum value of leaderboard scope</param>
    /// <param name="userData">
    /// ANDROID ONLY
    /// An optional code that will be returned in the response. Used to associate a function call to its response.
    /// A value of 0 is not recommended because 0 is the value returned when userData is not specified.
    /// </param>
    public static void RequestPercentileRanksForPlayer(string leaderboardId, string playerId, LeaderboardScope scope, int userData = 0)
    {
#if UNITY_EDITOR && UNITY_ANDROID
        // GameCircle only functions on device.
#elif UNITY_ANDROID
        JavaObject.Call("requestPercentileRanksForPlayer", leaderboardId, playerId, (int)scope, userData);
#else
        if (RequestPercentileRanksForPlayerCompleted != null)
        {
            RequestPercentileRanksForPlayerCompleted(AGSRequestPercentilesForPlayerResponse.GetPlatformNotSupportedResponse(leaderboardId, playerId, scope, userData));
        }
#endif
    }
 public static AGSRequestPercentilesForPlayerResponse GetBlankResponseWithError(string error,
                                                                                string leaderboardId = "",
                                                                                string playerId = "",
                                                                                LeaderboardScope scope = LeaderboardScope.GlobalAllTime,
                                                                                int userData = 0)
 {
     AGSRequestPercentilesForPlayerResponse response = new AGSRequestPercentilesForPlayerResponse ();
     response.error = error;
     response.userData = userData;
     response.leaderboardId = leaderboardId;
     response.scope = scope;
     response.leaderboard = AGSLeaderboard.GetBlankLeaderboard ();
     response.percentiles = new List<AGSLeaderboardPercentile>();
     response.userIndex = -1;
     response.scope = scope;
     response.playerId = playerId;
     return response;
 }
示例#6
0
    public static AGSRequestPercentilesForPlayerResponse GetBlankResponseWithError(string error,
                                                                                   string leaderboardId   = "",
                                                                                   string playerId        = "",
                                                                                   LeaderboardScope scope = LeaderboardScope.GlobalAllTime,
                                                                                   int userData           = 0)
    {
        AGSRequestPercentilesForPlayerResponse response = new AGSRequestPercentilesForPlayerResponse();

        response.error         = error;
        response.userData      = userData;
        response.leaderboardId = leaderboardId;
        response.scope         = scope;
        response.leaderboard   = AGSLeaderboard.GetBlankLeaderboard();
        response.percentiles   = new List <AGSLeaderboardPercentile>();
        response.userIndex     = -1;
        response.scope         = scope;
        response.playerId      = playerId;
        return(response);
    }
    private void OnRequestPercentilesForPlayerCompleted(AGSRequestPercentilesForPlayerResponse response)
    {
        if (!percentilesForPlayer.ContainsKey (response.leaderboardId)) {
            percentilesForPlayer.Add(response.leaderboardId, new Dictionary<string, List<string>>());
        }

        percentilesForPlayer [response.leaderboardId] [response.playerId] = new List<string> ();

        if (response.IsError ()) {
            percentilesForPlayer [response.leaderboardId] [response.playerId].Add(string.Format ("Error getting percentiles: {0}", response.error));
        } else {

            percentilesForPlayer [response.leaderboardId] [response.playerId].Add(string.Format("Leaderboard: {0}", response.leaderboard.ToString()));
            percentilesForPlayer [response.leaderboardId] [response.playerId].Add(string.Format ("Scope: {0}", response.scope.ToString()));

            foreach (AGSLeaderboardPercentile percentile in response.percentiles){
                percentilesForPlayer [response.leaderboardId] [response.playerId].Add(string.Format(percentileRankLabel, percentile.player.ToString(), percentile.percentile, percentile.score));
            }

            percentilesForPlayer [response.leaderboardId] [response.playerId].Add(string.Format("Requested player has an index of {0}.", response.userIndex));

        }
    }