Beispiel #1
0
 /// <summary>
 /// Decrease the achievement progress value based on a float amount
 /// </summary>
 /// <param name="achievement">Achievement object.</param>
 /// <param name="amount">Amount to decrease by.</param>
 public static void Decrease(Achievement achievement, int amount)
 {
     if (achievement.value > 0)
     {
         achievement.value -= amount;
     }
     AchievementController.CheckForCompletion(achievement);
     AchievementEvents.AchievementValueChanged(achievement);
 }
Beispiel #2
0
 /// <summary>
 /// Increment the achievement progress value based on a float amount
 /// </summary>
 /// <param name="achievement">Achievement object.</param>
 /// <param name="amount">Amount to increment by.</param>
 public static void Increment(Achievement achievement, int amount)
 {
     if (achievement.value < achievement.neededValue)
     {
         achievement.value += amount;
         AchievementController.CheckForCompletion(achievement);
         AchievementEvents.AchievementValueChanged(achievement);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Grant an achievement.
        /// This also completes the achievement regardless of progress.
        /// </summary>
        public static void Grant(Achievement achievement)
        {
            // Set the value to the required value
            // Set the completed value to true, as completed
            achievement.value = achievement.neededValue;

            achievement.completed = true;
            AchievementEvents.AchievementValueChanged(achievement);
            AchievementEvents.AchievementGranted(achievement);
        }
Beispiel #4
0
 /// <summary>
 /// Set an achievement's progress value directly
 /// </summary>
 /// <param name="achievement">Achievement object.</param>
 /// <param name="value">Value to set.</param>
 /// <param name="triggerGrant">Whether to trigger achievement notification if completed.</param>
 public static void SetValue(Achievement achievement, int value, bool triggerGrant = true)
 {
     achievement.value = value;
     if (achievement.value >= achievement.neededValue)
     {
         achievement.completed = true;
     }
     if (triggerGrant)
     {
         AchievementController.CheckForCompletion(achievement);
     }
     AchievementEvents.AchievementValueChanged(achievement);
 }