/// <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;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AmazonGameCircleExampleAchievements"/> class.
 /// </summary>
 public AmazonGameCircleExampleAchievements()
 {
     // This is used to test the GameCircle plugin's behaviour with invalid achievement information.
     // This achievement ID should not be in your game's list, to test what happens with invalid achievements.
     invalidAchievement          = new AGSAchievement();
     invalidAchievement.title    = "Invalid Achievement Title";
     invalidAchievement.id       = "Invalid Achievement ID";
     invalidAchievement.progress = 0;
 }
 /// <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="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>
 /// 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;
 }
Exemplo n.º 6
0
 public GC_Achievement(AGSAchievement achieve)
 {
     _title        = achieve.title;
     _id           = achieve.id;
     _description  = achieve.description;
     _progress     = achieve.progress;
     _pointValue   = achieve.pointValue;
     _isHidden     = achieve.isHidden;
     _isUnlocked   = achieve.isUnlocked;
     _position     = achieve.position;
     _dateUnlocked = achieve.dateUnlocked;
 }
Exemplo n.º 7
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;
    }
 /**
  * callback method for native code
  **/
 public static void RequestAchievementsSucceeded(string json)
 {
     if (RequestAchievementsSucceededEvent != null)
     {
         var Achievements = new List <AGSAchievement>();
         var list         = json.arrayListFromJson();
         foreach (Hashtable ht in list)
         {
             Achievements.Add(AGSAchievement.fromHashtable(ht));
         }
         RequestAchievementsSucceededEvent(Achievements);
     }
 }
Exemplo n.º 9
0
    /// <summary>
    /// Displays an individual achievement.
    /// </summary>
    /// <param name='achievement'>
    /// The achievement to display.
    /// </param>
    void DisplayAchievement(AGSAchievement achievement)
    {
        // Place a box around each achievement, to make it clear in the UI
        // what controls are for what achievement.
        GUILayout.BeginVertical(GUI.skin.box);

        // If this achievement has not been added to the foldout dictionary, add it.
        if (!achievementsFoldout.ContainsKey(achievement.id))
        {
            achievementsFoldout.Add(achievement.id, false);
        }

        // Display a foldout for this achievement.
        // Foldouts keep the menu tidy.
        achievementsFoldout[achievement.id] = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout[achievement.id], string.Format(achievementProgressLabel, achievement.id));

        // If the foldout is open, display the achievement information.
        if (achievementsFoldout[achievement.id])
        {
            // The controls for automatically word wrapping a label are not great,
            // so replacing every third comma in the string returned from the achievement's toString function
            // will allow for a cleaner display of each achievement's data
            AmazonGUIHelpers.AnchoredLabel(AddNewlineEveryThirdComma(achievement.ToString()), TextAnchor.UpperCenter);

            // if this achievement has no pending progress submissions, display information to submit an update.
            if (!achievementsSubmissionStatus.ContainsKey(achievement.id) || string.IsNullOrEmpty(achievementsSubmissionStatus[achievement.id]))
            {
                // Display a centered slider, with the minimum value on the left, and maximum value on the right.
                // This lets the user select a value for the achievement's progress.
                achievement.progress = AmazonGUIHelpers.DisplayCenteredSlider(achievement.progress, achievementMinValue, achievementMaxValue, achievementPercent);

                // This button submits an update to the achievement's progress to the GameCircle plugin.
                if (GUILayout.Button(submitAchievementButtonLabel))
                {
                    SubmitAchievement(achievement.id, achievement.progress);
                }
            }
            else
            {
                // If the achievement update is in the process of being submitted, display the submission status.
                AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatus[achievement.id]);

                if (achievementsSubmissionStatusMessage.ContainsKey(achievement.id) && !string.IsNullOrEmpty(achievementsSubmissionStatusMessage[achievement.id]))
                {
                    AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatusMessage[achievement.id]);
                }
            }
        }
        GUILayout.EndVertical();
    }
Exemplo n.º 10
0
 public static AGSAchievement GetBlankAchievement()
 {
     AGSAchievement achievement = new AGSAchievement ();
     achievement.title = "";
     achievement.id = "";
     achievement.description = "";
     achievement.pointValue = 0;
     achievement.isHidden = false;
     achievement.isUnlocked = false;
     achievement.progress = 0.0f;
     achievement.position = 0;
     achievement.dateUnlocked = System.DateTime.MinValue;
     return achievement;
 }
Exemplo n.º 11
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;
    }
Exemplo n.º 12
0
    public static AGSAchievement GetBlankAchievement()
    {
        AGSAchievement achievement = new AGSAchievement();

        achievement.title        = "";
        achievement.id           = "";
        achievement.description  = "";
        achievement.pointValue   = 0;
        achievement.isHidden     = false;
        achievement.isUnlocked   = false;
        achievement.progress     = 0.0f;
        achievement.position     = 0;
        achievement.dateUnlocked = System.DateTime.MinValue;
        return(achievement);
    }
Exemplo n.º 13
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());
     }
 }
Exemplo n.º 14
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();
     }
 }
 public static AGSRequestAchievementsResponse FromJSON(string json)
 {
     try {
         AGSRequestAchievementsResponse response = new AGSRequestAchievementsResponse();
         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));
             }
         }
         return(response);
     } catch (Exception e) {
         AGSClient.LogGameCircleError(e.ToString());
         return(GetBlankResponseWithError(JSON_PARSE_ERROR));
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
 /// </summary>
 public AGSSocialAchievement()
 {
     achievement = AGSAchievement.GetBlankAchievement ();
 }
    /// <summary>
    /// creates object from hashtable
    /// </summary>
    /// <returns>
    /// The hashtable.
    /// </returns>
    /// <param name='ht'>
    /// Ht.
    /// </param>
    public static AGSAchievement fromHashtable( Hashtable ht )
    {
        var achievement = new AGSAchievement();
        achievement.title = getStringValue(ht,"title");
        achievement.id = getStringValue(ht,"id");
        achievement.decription = getStringValue (ht, "description");
        try{
            string str = getStringValue(ht,"pointValue");
            achievement.pointValue = int.Parse(str);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse pointValue from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("pointValue not found  " + e.Message);
        }

        try{
            string str = getStringValue(ht,"position");
            achievement.position = int.Parse(str);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse position from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("position not found " + e.Message);
        }

        try{
            string str = getStringValue(ht,"progress");
            achievement.progress = float.Parse(str);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse progress from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("progress not found " + e.Message);
        }

        try{
            string str = getStringValue(ht,"hidden");
            achievement.isHidden = bool.Parse(str);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse isHidden from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("isHidden not found " + e.Message);
        }

        try{
            string str = getStringValue(ht,"unlocked");
            achievement.isUnlocked = bool.Parse(str);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse isUnlocked from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("isUnlocked not found " + e.Message);
        }

        try{
            string str = getStringValue(ht,"dateUnlocked");
            long epochTimeMillis = long.Parse(str);
            achievement.dateUnlocked = getTimefromEpochTime(epochTimeMillis);
        }catch(FormatException e){
            AGSClient.Log("Unable to parse dateUnlocked from achievement " + e.Message);
        }catch(ArgumentNullException e){
            AGSClient.Log("dateUnlocked not found " + e.Message);
        }

        return achievement;
    }
    /// <summary>
    /// creates object from hashtable
    /// </summary>
    /// <returns>
    /// The hashtable.
    /// </returns>
    /// <param name='ht'>
    /// Ht.
    /// </param>
    public static AGSAchievement fromHashtable(Hashtable ht)
    {
        var achievement = new AGSAchievement();

        achievement.title      = getStringValue(ht, "title");
        achievement.id         = getStringValue(ht, "id");
        achievement.decription = getStringValue(ht, "description");
        try{
            string str = getStringValue(ht, "pointValue");
            achievement.pointValue = int.Parse(str);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse pointValue from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("pointValue not found  " + e.Message);
        }

        try{
            string str = getStringValue(ht, "position");
            achievement.position = int.Parse(str);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse position from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("position not found " + e.Message);
        }

        try{
            string str = getStringValue(ht, "progress");
            achievement.progress = float.Parse(str);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse progress from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("progress not found " + e.Message);
        }

        try{
            string str = getStringValue(ht, "hidden");
            achievement.isHidden = bool.Parse(str);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse isHidden from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("isHidden not found " + e.Message);
        }

        try{
            string str = getStringValue(ht, "unlocked");
            achievement.isUnlocked = bool.Parse(str);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse isUnlocked from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("isUnlocked not found " + e.Message);
        }

        try{
            string str             = getStringValue(ht, "dateUnlocked");
            long   epochTimeMillis = long.Parse(str);
            achievement.dateUnlocked = getTimefromEpochTime(epochTimeMillis);
        }catch (FormatException e) {
            AGSClient.Log("Unable to parse dateUnlocked from achievement " + e.Message);
        }catch (ArgumentNullException e) {
            AGSClient.Log("dateUnlocked not found " + e.Message);
        }

        return(achievement);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
 /// </summary>
 public AGSSocialAchievement()
 {
     achievement = null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievementDescription"/> class.
 /// </summary>
 public AGSSocialAchievementDescription()
 {
     achievement = null;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
 /// </summary>
 public AGSSocialAchievement()
 {
     achievement = AGSAchievement.GetBlankAchievement();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievement"/> class.
 /// </summary>
 public AGSSocialAchievement()
 {
     achievement = null;
 }
    /// <summary>
    /// Initializes a new instance of the <see cref="AmazonGameCircleExampleAchievements"/> class.
    /// </summary>
    private AmazonGameCircleExampleAchievements()
    {
        AGSAchievementsClient.RequestAchievementsCompleted += OnRequestAchievementsCompleted;
        AGSAchievementsClient.RequestAchievementsForPlayerCompleted += OnRequestAchievementsForFriendCompleted;
        AGSAchievementsClient.UpdateAchievementCompleted += OnUpdateAchievementCompleted;
        AGSPlayerClient.RequestFriendIdsCompleted += OnRequestFriendsCompleted;

        // This is used to test the GameCircle plugin's behaviour with invalid achievement information.
        // This achievement ID should not be in your game's list, to test what happens with invalid achievements.
        invalidAchievement = new AGSAchievement();
        invalidAchievement.title = "Invalid Achievement Title";
        invalidAchievement.id = "Invalid Achievement ID";
        invalidAchievement.progress = 0;
    }
    /// <summary>
    /// Displays an individual achievement.
    /// </summary>
    /// <param name='achievement'>
    /// The achievement to display.
    /// </param>
    void DisplayAchievement(AGSAchievement achievement)
    {
        // Place a box around each achievement, to make it clear in the UI
        // what controls are for what achievement.
        GUILayout.BeginVertical(GUI.skin.box);

        // If this achievement has not been added to the foldout dictionary, add it.
        if(!achievementsFoldout.ContainsKey(achievement.id)) {
            achievementsFoldout.Add(achievement.id,false);
        }

        // Display a foldout for this achievement.
        // Foldouts keep the menu tidy.
        achievementsFoldout[achievement.id] = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout[achievement.id],string.Format(achievementProgressLabel,achievement.id));

        // If the foldout is open, display the achievement information.
        if(achievementsFoldout[achievement.id]) {
            // The controls for automatically word wrapping a label are not great,
            // so replacing every third comma in the string returned from the achievement's toString function
            // will allow for a cleaner display of each achievement's data
            AmazonGUIHelpers.AnchoredLabel(AddNewlineEveryThirdComma(achievement.ToString()),TextAnchor.UpperCenter);

            // if this achievement has no pending progress submissions, display information to submit an update.
            if(!achievementsSubmissionStatus.ContainsKey(achievement.id) || string.IsNullOrEmpty(achievementsSubmissionStatus[achievement.id])) {

                // Display a centered slider, with the minimum value on the left, and maximum value on the right.
                // This lets the user select a value for the achievement's progress.
                achievement.progress = AmazonGUIHelpers.DisplayCenteredSlider(achievement.progress,achievementMinValue,achievementMaxValue,achievementPercent);

                // This button submits an update to the achievement's progress to the GameCircle plugin.
                if(GUILayout.Button(submitAchievementButtonLabel)) {
                    // Update the status of this achievement to show submission has begun.
                    achievementsSubmissionStatus[achievement.id] = string.Format(submittingInformationString);
                    // Submit the achievement update to the GameCircle plugin.
                    AGSAchievementsClient.UpdateAchievementProgress(achievement.id, achievement.progress);
                }
            }
            else {
                // If the achievement update is in the process of being submitted, display the submission status.
                AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatus[achievement.id]);

                if(achievementsSubmissionStatusMessage.ContainsKey(achievement.id) && !string.IsNullOrEmpty(achievementsSubmissionStatusMessage[achievement.id])) {
                    AmazonGUIHelpers.CenteredLabel(achievementsSubmissionStatusMessage[achievement.id]);
                }
            }
        }
        GUILayout.EndVertical();
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="AGSSocialAchievementDescription"/> class.
 /// </summary>
 public AGSSocialAchievementDescription()
 {
     achievement = null;
 }