コード例 #1
0
    /**
     * Sets the player prefs for the given achievement to become unlocked.
     *
     * @param id The id of the achievement.
     */
    private void UnlockAchievement(string id)
    {
        // no need to execute this method if the achievement is already unlocked.
        if (achievements[id].IsUnlocked())
        {
            return;
        }

        // notify our player prefs that the achievement is unlocked and send analytics info
        Analytics.CustomEvent("Achievement Unlocked: ", new Dictionary <string, object>
        {
            { "Achievement", achievements[id].GetDisplayName() },
        });
        PlayerPrefs.SetString(id, "unlocked");
        achievements[id].SetUnlocked();
        if (id.Contains("shop"))
        {
            shop.depositMoney(achievements[id].GetPayout());
        }
        else
        {
            scoreCounter.AddAchievementBounty(achievements[id].GetPayout());
        }
    }