Exemple #1
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.");
        }
    }
 void UnlockAchievement(int achievementNumberInList)
 {
     if (achievementNumberInList == -1)
     {
         achievementNameDisplay.text        = "HIGH SCORE";
         achievementDescriptionDisplay.text = "You've achieved a new high score.";
     }
     else
     {
         achievementNameDisplay.text        = Achievements[achievementNumberInList].name;
         achievementDescriptionDisplay.text = Achievements[achievementNumberInList].description;
         ShipCustomizationPanel.UnlockPart(Achievements[achievementNumberInList].partType, Achievements[achievementNumberInList].partNum);
         CustomAnalytics.SendAchievementUnlocked(Achievements[achievementNumberInList]);
     }
     anim.SetBool("Achievement appear", true);
     Invoke("AchievementDisappear", durationOfShowingAchievement);
     SaveGameManager.Save();
 }
Exemple #3
0
    //decided I'd try to only run this on an event(aka when the value changed) so after I add the value
    //I just call it on the script I added it from. plan on making methods later to make it simpler.
    /// <summary>
    /// make sure to call this after changing variables
    /// </summary>
    public static void AchievementCheck()
    {
        if (SaveGameManager.CheckHighScore(SCORE) && !_S._newHighScore)
        {
            _S._newHighScore = true;
            AchievementSettings highScoreSettings = new AchievementSettings();
            highScoreSettings.title       = _S.highScoreTitle;
            highScoreSettings.description = _S.highScoreDescription;
            highScoreSettings.count       = SCORE;
            _S._settingsQueue.Enqueue(highScoreSettings);
            UIScript.SetGameOverText("HIGH SCORE!");
        }
        foreach (AchievementSettings setting in _S.settings)
        {
            switch ((int)setting.achievementType)
            {
            case 0:                    //LuckyShot
                if (BULLET_WRAP_COUNT >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 1:                    //AsteroidHitCount
                if (ASTEROIDS_HIT >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 2:                    //BulletsFired
                if (BULLETS_FIRED >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 3:                    //Points
                if (SCORE >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            case 4:                    //LevelsComplete
                if (AsteraX.GetLevel() >= setting.count && !setting.complete)
                {
                    setting.complete = true;
                    _S._settingsQueue.Enqueue(setting);
                    CustomAnalytics.SendAchievementUnlocked(setting);
                }
                break;

            default:
                break;
            }

            UIScript.UnlockToggleFromAchievement(setting);
        }
        SaveGameManager.Save();
    }