/// <summary>
    /// Syncables the method to list behavior.
    /// </summary>
    /// <returns>
    /// The method to list behavior.
    /// </returns>
    /// <param name='syncableMethod'>
    /// Syncable method.
    /// </param>
    SyncableListBehavior SyncableMethodToListBehavior(SyncableMethod syncableMethod)
    {
        switch (syncableMethod)
        {
        case SyncableMethod.getHighestNumber:
        case SyncableMethod.getHighNumberList:
            return(SyncableListBehavior.HighNumber);

        case SyncableMethod.getLatestNumber:
        case SyncableMethod.getLatestNumberList:
            return(SyncableListBehavior.LatestNumber);

        case SyncableMethod.getLowestNumber:
        case SyncableMethod.getLowNumberList:
            return(SyncableListBehavior.LowNumber);

        case SyncableMethod.getLatestString:
        case SyncableMethod.getLatestStringList:
            return(SyncableListBehavior.LatestString);

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled AGSSyncableNumberList type {0}", syncableMethod.ToString()));
            // still need to return something if error logging is set to a level less than exception.
            return(SyncableListBehavior.HighNumber);
        }
    }
Exemple #2
0
 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>
 /// Initializes a new instance of the <see cref="AGSPlayer"/> class.
 /// This constructor is private because this class should only be
 /// instantiated through fromHashtable
 /// </summary>
 private AGSPlayer()
 {
     alias     = null;
     playerId  = null;
     avatarUrl = null;
     AGSClient.LogGameCircleError("AGSPlayer was instantiated without valid information.");
 }
 /// <summary>
 /// Loads the friends.
 /// </summary>
 /// <param name='user'>
 /// User.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadFriends(ILocalUser user, System.Action <bool> callback)
 {
     if (user == null)
     {
         AGSClient.LogGameCircleError("LoadFriends \"user\" argument should not be null");
         return;
     }
     user.LoadFriends(callback);
 }
 /// <summary>
 /// Loads this local user's friends list.
 /// </summary>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadFriends(System.Action <bool> callback)
 {
     AGSClient.LogGameCircleError("ILocalUser.LoadFriends is not available for GameCircle");
     // Call the callback with a "false" to let it know the friends list was not loaded.
     if (null != callback)
     {
         callback(false);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievementDescription"/> class.
 /// </summary>
 /// <param name='achievement'>
 /// Achievement.
 /// </param>
 public AGSSocialAchievementDescription(AGSAchievement achievement)
 {
     if (null == achievement)
     {
         AGSClient.LogGameCircleError("AGSSocialAchievementDescription constructor \"achievement\" argument should not be null");
         return;
     }
     this.achievement = achievement;
     id = achievement.id;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialLeaderboard"/> class.
 /// </summary>
 /// <param name='leaderboard'>
 /// Leaderboard.
 /// </param>
 public AGSSocialLeaderboard(AGSLeaderboard leaderboard)
 {
     if (null == leaderboard)
     {
         AGSClient.LogGameCircleError("AGSSocialLeaderboard constructor \"leaderboard\" argument should not be null");
         return;
     }
     this.leaderboard = leaderboard;
     id = leaderboard.id;
 }
 /// <summary>
 /// Loads the scores.
 /// </summary>
 /// <param name='board'>
 /// Board.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadScores(ILeaderboard board, System.Action <bool> callback)
 {
     // This function doesn't do anything with a null leaderboard.
     if (null == board)
     {
         AGSClient.LogGameCircleError("LoadScores \"board\" argument should not be null");
         return;
     }
     board.LoadScores(callback);
 }
 /// <summary>
 /// Gets the loading status of the leaderboard.
 /// </summary>
 /// <returns>
 /// The loading.
 /// </returns>
 /// <param name='board'>
 /// If set to <c>true</c> board.
 /// </param>
 public bool GetLoading(ILeaderboard board)
 {
     // This function doesn't do anything with a null leaderboard.
     if (null == board)
     {
         AGSClient.LogGameCircleError("GetLoading \"board\" argument should not be null");
         return(false);
     }
     return(board.loading);
 }
    /// <summary>
    /// Initializes the native function calls.
    /// </summary>
    void InitializeNativeFunctionCalls()
    {
#if !UNITY_EDITOR
        switch (listBehavior)
        {
        case SyncableListBehavior.HighNumber:
            setListMaxSize = _AmazonGCWSSetHighNumberListMaxSize;
            getListMaxSize = _AmazonGCWSGetHighNumberListMaxSize;
            isListSet      = _AmazonGCWSHighNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSHighNumberListAddStringAndMetadataAsJSON;
            addStringToList             = _AmazonGCWSHighNumberListAddString;
            getTimestampAtIndex         = _AmazonGCWSGetHighNumberListTimestampAtIndex;
            getMetadataAtIndex          = _AmazonGCWSGetHighNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetHighNumberListCount;
            break;

        case SyncableListBehavior.LatestNumber:
            setListMaxSize = _AmazonGCWSSetLatestNumberListMaxSize;
            getListMaxSize = _AmazonGCWSGetLatestNumberListMaxSize;
            isListSet      = _AmazonGCWSLatestNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLatestNumberListAddStringAndMetadataAsJSON;
            addStringToList             = _AmazonGCWSLatestNumberListAddString;
            getTimestampAtIndex         = _AmazonGCWSGetLatestNumberListTimestampAtIndex;
            getMetadataAtIndex          = _AmazonGCWSGetLatestNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLatestNumberListCount;
            break;

        case SyncableListBehavior.LowNumber:
            setListMaxSize = _AmazonGCWSSetLowNumberListMaxSize;
            getListMaxSize = _AmazonGCWSGetLowNumberListMaxSize;
            isListSet      = _AmazonGCWSLowNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLowNumberListAddStringAndMetadataAsJSON;
            addStringToList             = _AmazonGCWSLowNumberListAddString;
            getTimestampAtIndex         = _AmazonGCWSGetLowNumberListTimestampAtIndex;
            getMetadataAtIndex          = _AmazonGCWSGetLowNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLowNumberListCount;
            break;

        case SyncableListBehavior.LatestString:
            setListMaxSize = _AmazonGCWSSetLatestStringListMaxSize;
            getListMaxSize = _AmazonGCWSGetLatestStringListMaxSize;
            isListSet      = _AmazonGCWSLatestStringListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLatestStringListAddStringAndMetadataAsJSON;
            addStringToList             = _AmazonGCWSLatestStringListAddString;
            getTimestampAtIndex         = _AmazonGCWSGetLatestStringListTimestampAtIndex;
            getMetadataAtIndex          = _AmazonGCWSGetLatestStringListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLatestStringListCount;
            break;

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync list behavior {0}", listBehavior.ToString()));
            break;
        }
#endif
    }
Exemple #11
0
 /// <summary>
 /// creates a new instance of the <see cref="AGSPlayer"/> class from a hashtable
 /// </summary>
 /// <returns>
 /// A <see cref="AGSPlayer"/> class created from the passed in hashtable.
 /// </returns>
 /// <param name='hashtable'>
 /// hashtable.
 /// </param>
 public static AGSPlayer fromHashtable(Hashtable playerDataAsHashtable)
 {
     try {
         return(new AGSPlayer(playerDataAsHashtable.ContainsKey(aliasKey) ? playerDataAsHashtable[aliasKey].ToString() : "",
                              playerDataAsHashtable.ContainsKey(playerIdKey) ? playerDataAsHashtable[playerIdKey].ToString() : "",
                              playerDataAsHashtable.ContainsKey(avatarUrlKey) ? playerDataAsHashtable[avatarUrlKey].ToString() : ""));
     } catch (Exception e) {
         AGSClient.LogGameCircleError("Returning blank player due to exception getting player from hashtable: " + e.ToString());
         return(GetBlankPlayer());
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
 /// </summary>
 /// <param name='achievement'>
 /// Achievement.
 /// </param>
 public AGSSocialAchievement(AGSAchievement achievement)
 {
     if (null == achievement)
     {
         AGSClient.LogGameCircleError("AGSSocialAchievement constructor \"achievement\" argument should not be null");
         return;
     }
     this.achievement = achievement;
     id = achievement.id;
     percentCompleted = achievement.progress;
 }
 /// <summary>
 /// Loads the achievements.
 /// </summary>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadAchievements(System.Action <IAchievement[]> callback)
 {
     // The callback argument should not be null for this function.
     if (null == callback)
     {
         AGSClient.LogGameCircleError("LoadAchievements \"callback\" argument should not be null");
         return;
     }
     loadAchievementsCallbacks.Add(requestID, callback);
     AGSAchievementsClient.RequestAchievements(requestID++);
 }
    /// <summary>
    /// Initializes the native function calls.
    /// </summary>
    void InitializeNativeFunctionCalls()
    {
        // Does nothing in editor mode so these functions remain null.
#if !UNITY_EDITOR
        switch (listBehavior)
        {
        case SyncableListBehavior.HighNumber:
            addNumberAsInt                = _AmazonGCWSNumberListAddHighInt;
            addNumberAsInt64              = _AmazonGCWSNumberListAddHighInt64;
            addNumberAsDouble             = _AmazonGCWSNumberListAddHighDouble;
            addNumberAsIntWithMetadata    = _AmazonGCWSNumberListAddHighIntJSONMetadata;
            addNumberAsInt64WithMetadata  = _AmazonGCWSNumberListAddHighInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddHighDoubleJSONMetadata;
            getValueAtIndexAsInt          = _AmazonGCWSGetHighNumberListElementValueAsInt;
            getValueAtIndexAsInt64        = _AmazonGCWSGetHighNumberListElementValueAsInt64;
            getValueAtIndexAsDouble       = _AmazonGCWSGetHighNumberListElementValueAsDouble;
            getValueAtIndexAsString       = _AmazonGCWSGetHighNumberListElementValueAsString;
            break;

        case SyncableListBehavior.LatestNumber:
            addNumberAsInt                = _AmazonGCWSNumberListAddLatestInt;
            addNumberAsInt64              = _AmazonGCWSNumberListAddLatestInt64;
            addNumberAsDouble             = _AmazonGCWSNumberListAddLatestDouble;
            addNumberAsIntWithMetadata    = _AmazonGCWSNumberListAddLatestIntJSONMetadata;
            addNumberAsInt64WithMetadata  = _AmazonGCWSNumberListAddLatestInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddLatestDoubleJSONMetadata;
            getValueAtIndexAsInt          = _AmazonGCWSGetLatestNumberListElementValueAsInt;
            getValueAtIndexAsInt64        = _AmazonGCWSGetLatestNumberListElementValueAsInt64;
            getValueAtIndexAsDouble       = _AmazonGCWSGetLatestNumberListElementValueAsDouble;
            getValueAtIndexAsString       = _AmazonGCWSGetLatestNumberListElementValueAsString;
            break;

        case SyncableListBehavior.LowNumber:
            addNumberAsInt                = _AmazonGCWSNumberListAddLowInt;
            addNumberAsInt64              = _AmazonGCWSNumberListAddLowInt64;
            addNumberAsDouble             = _AmazonGCWSNumberListAddLowDouble;
            addNumberAsIntWithMetadata    = _AmazonGCWSNumberListAddLowIntJSONMetadata;
            addNumberAsInt64WithMetadata  = _AmazonGCWSNumberListAddLowInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddLowDoubleJSONMetadata;
            getValueAtIndexAsInt          = _AmazonGCWSGetLowNumberListElementValueAsInt;
            getValueAtIndexAsInt64        = _AmazonGCWSGetLowNumberListElementValueAsInt64;
            getValueAtIndexAsDouble       = _AmazonGCWSGetLowNumberListElementValueAsDouble;
            getValueAtIndexAsString       = _AmazonGCWSGetLowNumberListElementValueAsString;
            break;

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync list behavior {0}", listBehavior.ToString()));
            break;
        }
#endif
    }
 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 AGSSubmitScoreResponse FromJSON(string json)
 {
     try {
         AGSSubmitScoreResponse response = new AGSSubmitScoreResponse();
         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() : "";
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
Exemple #17
0
    /// <summary>
    /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
    /// </summary>
    /// <param name='achievement'>
    /// Achievement.
    /// </param>
    public AGSSocialAchievement(AGSAchievement achievement)
    {
        if (null == achievement)
        {
            AGSClient.LogGameCircleError("AGSSocialAchievement constructor \"achievement\" argument should not be null");
            achievement = AGSAchievement.GetBlankAchievement();
        }
        else
        {
            this.achievement = achievement;
        }
        id = achievement.id;

        percentCompleted = achievement.progress;
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialLeaderboardScore"/> class.
 /// </summary>
 /// <param name='score'>
 /// Score.
 /// </param>
 /// <param name='leaderboard'>
 /// Leaderboard.
 /// </param>
 public AGSSocialLeaderboardScore(AGSScore score, AGSLeaderboard leaderboard)
 {
     if (null == score)
     {
         AGSClient.LogGameCircleError("AGSSocialLeaderboardScore constructor \"score\" argument should not be null");
         return;
     }
     if (null == leaderboard)
     {
         AGSClient.LogGameCircleError("AGSSocialLeaderboardScore constructor \"leaderboard\" argument should not be null");
         return;
     }
     this.score    = score;
     leaderboardID = leaderboard.id;
     value         = score.scoreValue;
 }
    /// <summary>
    /// Gets the hash set from the iOS library as JSON formatted string.
    /// </summary>
    /// <returns>
    /// The hash set as JSON formatted string.
    /// </returns>
    /// <param name='method'>
    /// The method to call.
    /// </param>
    string getHashSetAsJSON(HashSetMethod method)
    {
        // Having a method per hash set retrieval matches
        // the iOS SDK, and the Android half of the plugin's behavior.
        switch (method)
        {
        case HashSetMethod.getDeveloperStringKeys:
            return(_AmazonGCWSGetDeveloperStringKeysAsJSON());

        case HashSetMethod.getAccumulatingNumberKeys:
            return(_AmazonGCWSGetAccumulatingNumberKeysAsJSON());

        case HashSetMethod.getHighestNumberKeys:
            return(_AmazonGCWSGetHighestNumberKeysAsJSON());

        case HashSetMethod.getHighNumberListKeys:
            return(_AmazonGCWSGetHighNumberListKeysAsJSON());

        case HashSetMethod.getLatestNumberKeys:
            return(_AmazonGCWSGetLatestNumberKeysAsJSON());

        case HashSetMethod.getLatestNumberListKeys:
            return(_AmazonGCWSGetLatestNumberListKeysAsJSON());

        case HashSetMethod.getLatestStringKeys:
            return(_AmazonGCWSGetLatestStringKeysAsJSON());

        case HashSetMethod.getLatestStringListKeys:
            return(_AmazonGCWSGetLatestStringListKeysAsJSON());

        case HashSetMethod.getLowestNumberKeys:
            return(_AmazonGCWSGetLowestNumberKeysAsJSON());

        case HashSetMethod.getLowNumberListKeys:
            return(_AmazonGCWSGetLowNumberListKeysAsJSON());

        case HashSetMethod.getMapKeys:
            return(_AmazonGCWSGetMapKeysAsJSON());

        case HashSetMethod.getStringSetKeys:
            return(_AmazonGCWSGetStringSetKeysAsJSON());

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled hash set method {0}", method.ToString()));
            return(null);
        }
    }
Exemple #20
0
 public static AGSRequestScoreResponse FromJSON(string json)
 {
     try {
         AGSRequestScoreResponse response = new AGSRequestScoreResponse();
         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() : "";
         response.rank          = hashtable.ContainsKey("rank") ? int.Parse(hashtable ["rank"].ToString()) : -1;
         response.score         = hashtable.ContainsKey("score") ? long.Parse(hashtable ["score"].ToString()) : -1;
         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>
 /// Initializes a new instance of the <see cref="AGSSocialLeaderboard"/> class.
 /// </summary>
 /// <param name='leaderboard'>
 /// Leaderboard.
 /// </param>
 public AGSSocialLeaderboard(AGSLeaderboard leaderboard)
 {
     if (null == leaderboard)
     {
         AGSClient.LogGameCircleError("AGSSocialLeaderboard constructor \"leaderboard\" argument should not be null");
         this.leaderboard = AGSLeaderboard.GetBlankLeaderboard();
     }
     else
     {
         this.leaderboard = leaderboard;
     }
     id               = leaderboard.id;
     scores           = new AGSSocialLeaderboardScore[0];
     localPlayerScore = -1;
     localPlayerRank  = -1;
     _timeScope       = TimeScope.AllTime;
 }
Exemple #22
0
 public static AGSAchievement fromHashtable(Hashtable hashtable)
 {
     try {
         AGSAchievement achievement = new AGSAchievement();
         achievement.title        = hashtable["achievementTitle"].ToString();
         achievement.id           = hashtable["achievementId"].ToString();
         achievement.description  = hashtable["achievementDescription"].ToString();
         achievement.progress     = float.Parse(hashtable["achievementProgress"].ToString());
         achievement.pointValue   = int.Parse(hashtable["achievementPointValue"].ToString());
         achievement.position     = int.Parse(hashtable["achievementPosition"].ToString());
         achievement.isUnlocked   = bool.Parse(hashtable["achievementUnlocked"].ToString());
         achievement.isHidden     = bool.Parse(hashtable["achievementHidden"].ToString());
         achievement.dateUnlocked = getTimefromEpochTime(long.Parse(hashtable["achievementDateUnlocked"].ToString()));
         return(achievement);
     } catch (Exception e) {
         AGSClient.LogGameCircleError("Returning blank achievement due to exception getting achievement from hashtable: " + e.ToString());
         return(GetBlankAchievement());
     }
 }
Exemple #23
0
 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));
     }
 }
    /// <summary>
    /// Loads the achievement descriptions.
    /// </summary>
    /// <param name='callback'>
    /// Callback.
    /// </param>
    public void LoadAchievementDescriptions(System.Action <IAchievementDescription[]> callback)
    {
        // The callback argument should not be null for this function.
        if (null == callback)
        {
            AGSClient.LogGameCircleError("LoadAchievementDescriptions \"callback\" argument should not be null");
            return;
        }

        // Transform the passed in callback action to the type of callback the GameCircle plugin expects.
        AGSAchievementsClient.RequestAchievementsFailedEvent    += (e) => { callback(null); };
        AGSAchievementsClient.RequestAchievementsSucceededEvent += (achievements) => {
            AGSSocialAchievementDescription [] descriptions = new AGSSocialAchievementDescription[achievements.Count];
            for (int achievementIndex = 0; achievementIndex < achievements.Count; achievementIndex++)
            {
                descriptions[achievementIndex] = new AGSSocialAchievementDescription(achievements[achievementIndex]);
            }
            callback(descriptions);
        };
        AGSAchievementsClient.RequestAchievements();
    }
    /// <summary>
    /// Initializes the behavior of the syncable number element for iOS.
    /// </summary>
    /// <param name='syncableMethod'>
    /// Syncable method.
    /// </param>
    SyncableNumberBehavior SyncableBehaviorFromSyncableMethod(SyncableMethod syncableMethod)
    {
        switch (syncableMethod)
        {
        case SyncableMethod.getHighestNumber:
        case SyncableMethod.getHighNumberList:
            return(SyncableNumberBehavior.Highest);

        case SyncableMethod.getLatestNumber:
        case SyncableMethod.getLatestNumberList:
            return(SyncableNumberBehavior.Latest);

        case SyncableMethod.getLowestNumber:
        case SyncableMethod.getLowNumberList:
            return(SyncableNumberBehavior.Lowest);

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled SyncableNumberElement type {0}", syncableMethod.ToString()));
            return(SyncableNumberBehavior.Latest);
        }
    }
 public static AGSRequestFriendIdsResponse FromJSON(string json)
 {
     try {
         AGSRequestFriendIdsResponse response = new AGSRequestFriendIdsResponse();
         Hashtable hashtable = json.hashtableFromJson();
         response.error     = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : "";
         response.userData  = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0;
         response.friendIds = new List <string> ();
         if (hashtable.ContainsKey("friendIds"))
         {
             foreach (string friendPlayerId in hashtable["friendIds"] as ArrayList)
             {
                 response.friendIds.Add(friendPlayerId);
             }
         }
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
Exemple #27
0
 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));
     }
 }
 /// <summary>
 /// Sets the user filter.
 /// </summary>
 /// <param name='userIDs'>
 /// User I ds.
 /// </param>
 public void SetUserFilter(string[] userIDs)
 {
     AGSClient.LogGameCircleError("ILeaderboard.SetUserFilter is not available for GameCircle");
 }
Exemple #29
0
    /// <summary>
    /// Optional metadata associated with this SyncableElement.  A
    /// non-null, unmodifiable map is returned.
    /// </summary>
    /// <returns>dictionary containing key,value map of metadata</returns>
    public Dictionary <string, string> GetMetadata()
    {
#if UNITY_ANDROID
        Dictionary <string, string> dictionary = new Dictionary <string, string>();

        AndroidJNI.PushLocalFrame(10);
        AndroidJavaObject javaMap = javaObject.Call <AndroidJavaObject>("getMetadata");
        if (javaMap == null)
        {
            AGSClient.LogGameCircleError("Whispersync element was unable to retrieve metadata java map");
            return(dictionary);
        }

        AndroidJavaObject javaSet = javaMap.Call <AndroidJavaObject>("keySet");
        if (javaSet == null)
        {
            AGSClient.LogGameCircleError("Whispersync element was unable to retrieve java keyset");
            return(dictionary);
        }


        AndroidJavaObject javaIterator = javaSet.Call <AndroidJavaObject>("iterator");
        if (javaIterator == null)
        {
            AGSClient.LogGameCircleError("Whispersync element was unable to retrieve java iterator");
            return(dictionary);
        }

        string key, val;
        while (javaIterator.Call <bool>("hasNext"))
        {
            key = javaIterator.Call <string>("next");
            if (key != null)
            {
                val = javaMap.Call <string>("get", key);
                if (val != null)
                {
                    dictionary.Add(key, val);
                }
            }
        }
        AndroidJNI.PopLocalFrame(System.IntPtr.Zero);
        return(dictionary);
#elif UNITY_IOS
        string metadataAsJSON = null;
        if (null != getMetadata)
        {
            metadataAsJSON = getMetadata(key);
        }
        // if getMetadata was not available, or getMetadata returned a null / empty string,
        // return null.
        if (string.IsNullOrEmpty(metadataAsJSON))
        {
            return(null);
        }
        // Convert the string to a hashtable.
        Hashtable jsonAsHashtable = metadataAsJSON.hashtableFromJson();
        // Convert the hashtable to a ditionary.
        Dictionary <string, string> dictionary = new Dictionary <string, string>();
        foreach (string key in jsonAsHashtable.Keys)
        {
            dictionary.Add(key, jsonAsHashtable[key] as string);
        }
        return(dictionary);
#else
        return(default(Dictionary <string, string>));
#endif
    }
Exemple #30
0
    /// <summary>
    /// Initializes the native function calls.
    /// </summary>
    void InitializeNativeFunctionCalls()
    {
#if !UNITY_EDITOR
        if (null != setOwner)
        {
            // Let the set get the timestamp of the element,
            // using the key of this element.
            getTimestamp = setOwner.GetTimestampForValue;
            getMetadata  = setOwner.GetMetadataForValueAsJSON;
        }
        // else if the element is in a list,
        else if (null != listOwner && listIndex.HasValue)
        {
            // Create a local delegate that ignores the passed in key and instead
            // requests the information based on the list index.
            getTimestamp = (k) => { return(listOwner.GetTimestampAtIndex(listIndex.Value)); };
            getMetadata  = (k) => { return(listOwner.GetMetadataAtIndex(listIndex.Value)); };
        }
        else
        {
            // Doing a single switch here keeps each individual function smaller and cleaner.
            switch (method)
            {
            case SyncableMethod.getHighestNumber:
                getTimestamp = _AmazonGCWSGetElementTimestampHighestNumber;
                getMetadata  = _AmazonGCWSGetMetadataJSONHighestNumber;
                break;

            case SyncableMethod.getLatestNumber:
                getTimestamp = _AmazonGCWSGetElementTimestampLatestNumber;
                getMetadata  = _AmazonGCWSGetMetadataJSONLatestNumber;
                break;

            case SyncableMethod.getLatestString:
                getTimestamp = _AmazonGCWSGetElementTimestampLatestString;
                getMetadata  = _AmazonGCWSGetMetadataJSONLatestString;
                break;

            case SyncableMethod.getLowestNumber:
                getTimestamp = _AmazonGCWSGetElementTimestampLowestNumber;
                getMetadata  = _AmazonGCWSGetMetadataJSONLowestNumber;
                break;

            case SyncableMethod.getAccumulatingNumber:
            case SyncableMethod.getHighNumberList:
            case SyncableMethod.getLatestNumberList:
            case SyncableMethod.getLatestStringList:
            case SyncableMethod.getLowNumberList:
            case SyncableMethod.getMap:
            case SyncableMethod.getStringSet:
                // these syncable method types are not actually SyncableElements, and do not have metadata.
                AGSClient.LogGameCircleError(string.Format("Whispersync SyncableElement is an unsupported method type {0}", method.ToString()));
                break;

            default:
                AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync SyncableElement method {0}", method.ToString()));
                break;
            }
        }
#endif
    }