/// <summary>
    /// Increments one of the StepRecords that can unlock Achievements.
    /// </summary>
    /// <param name="stepType">The eStepType to increment.</param>
    /// <param name="num">The amount to increment (default = 1).</param>
    static public void AchievementStep(Achievement.eStepType stepType, int num = 1)
    {
        StepRecord sRec = STEP_REC_DICT[stepType];

        if (sRec != null)
        {
            sRec.Progress(num);

            // Iterate through all of the possible Achievements and see if the step
            //  completes the Achievement
            foreach (Achievement ach in S.achievements)
            {
                if (!ach.complete)
                {
                    // Pass the step information to the Achievement, to see if it is completed
                    if (ach.CheckCompletion(stepType, sRec.num))
                    {
                        // The result is true if the Achievement was completed
                        AnnounceAchievementCompletion(ach);
                    }
                }
            }
        }
        else
        {
            Debug.LogWarning("AchievementManager:AchievementStep( " + stepType + ", " + num + " )"
                             + "was passed a stepType that is not in STEP_REC_DICT.");
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Increments one of the StepRecords that can unlock Achievements.
    /// </summary>
    /// <param name="stepType">The eStepType to increment.</param>
    /// <param name="num">The amount to increment (default = 1).</param>
    static public void AchievementStep(Achievement.eStepType stepType, int num = 1)
    {
        StepRecord sRec = STEP_REC_DICT[stepType];

        if (sRec != null)
        {
            sRec.Progress(num);

            // Iterate through all of the possible Achievements and see if the step
            //  completes the Achievement
            foreach (Achievement ach in S.achievements)
            {
                if (!ach.complete)
                {
                    // Pass the step information to the Achievement, to see if it is completed
                    if (ach.CheckCompletion(stepType, sRec.num))
                    {
                        // The result is true if the Achievement was newly completed
                        AnnounceAchievementCompletion(ach);

                        // Tell Unity Analytics that the Achievement has been completed
                        CustomAnalytics.SendAchievementUnlocked(ach);

                        // Also save the game any time we complete an Achievement
                        SaveGameManager.Save();
                    }
                }
            }
        }
        else
        {
            Debug.LogWarning("AchievementManager:AchievementStep( " + stepType + ", " + num + " )"
                             + "was passed a stepType that is not in STEP_REC_DICT.");
        }
    }
Esempio n. 3
0
 /// <summary>
 /// 获取任务执行情况数组
 /// </summary>
 /// <param name="count"></param>
 /// <returns></returns>
 public string[] GetStepArray(int count)
 {
     if (_stepArray == null)
     {
         if (!string.IsNullOrEmpty(StepRecord))
         {
             _stepArray = StepRecord.Split(',');
         }
         else
         {
             _stepArray = new string[count];
         }
     }
     else if (_stepArray.Length < count)
     {
         var newArray = new string[count];
         for (int i = 0; i < _stepArray.Length; i++)
         {
             newArray[i] = _stepArray[i];
         }
         _stepArray = newArray;
     }
     return(_stepArray);
 }