/// <summary>
 ///  callback method for native code to communicate events back to unity
 /// </summary>
 public static void PlayerReceived(string json)
 {
     if (PlayerReceivedEvent != null)
     {
         var ht = json.hashtableFromJson();
         PlayerReceivedEvent(AGSPlayer.fromHashtable(ht));
     }
 }
Пример #2
0
    public static AGSScore fromHashtable(Hashtable scoreHashTable)
    {
        var score = new AGSScore();

        score.player      = AGSPlayer.fromHashtable(scoreHashTable["player"] as Hashtable);
        score.rank        = int.Parse(scoreHashTable["rank"].ToString());
        score.scoreString = scoreHashTable["scoreString"].ToString();
        score.scoreValue  = long.Parse(scoreHashTable["score"].ToString());
        return(score);
    }
    public static AGSLeaderboardPercentile fromHashTable(Hashtable percentilesHashtable)
    {
        AGSLeaderboardPercentile leaderboardPercentile = new AGSLeaderboardPercentile();

        try {
            leaderboardPercentile.percentile = int.Parse(percentilesHashtable[percentileKey].ToString());
            leaderboardPercentile.score      = long.Parse(percentilesHashtable[scoreKey].ToString());
        } catch (FormatException e) {
            AGSClient.Log("Unable to parse percentile item " + e.Message);
        }
        leaderboardPercentile.player = AGSPlayer.fromHashtable(percentilesHashtable[playerKey] as Hashtable);
        return(leaderboardPercentile);
    }
 public static AGSRequestPlayerResponse FromJSON(string json)
 {
     try {
         AGSRequestPlayerResponse response = new AGSRequestPlayerResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error    = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : "";
         response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0;
         response.player   = hashtable.ContainsKey("player") ? AGSPlayer.fromHashtable(hashtable ["player"] as Hashtable) : AGSPlayer.GetBlankPlayer();
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
 public static AGSRequestBatchFriendsResponse FromJSON(string json)
 {
     try {
         AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error    = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : "";
         response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0;
         response.friends  = new List <AGSPlayer>();
         if (hashtable.ContainsKey("friends"))
         {
             foreach (Hashtable playerHashtable in hashtable["friends"] as ArrayList)
             {
                 response.friends.Add(AGSPlayer.fromHashtable(playerHashtable));
             }
         }
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }