Esempio n. 1
0
    /// <summary>
    /// This method unlocks achievements, if found - and not already unlocked.
    /// </summary>
    /// <param name="id">The achievement ID of the achievement to be unlocked.</param>
    private void UnlockAchievement(AchievementID id)
    {
        Achievement ach;
        bool        found = achievements.TryGetValue(id, out ach);

        if (found && !ach.achieved)
        {
            ach.achieved = true;

            // mark it down
            SteamUserStats.SetAchievement(id.ToString());
            achievementCounter++;

            //unlock meta-achievement
            if (achievementCounter == 15)
            {
                UnlockAchievement(AchievementID.ACH_HALF_OF_ALL_ACHIEVEMENTS);
            }

            // store stats
            storeStats = true;
        }
        else if (!found)
        {
            Debug.Log("AchievementID not found in Dictionary");
        }
    }
Esempio n. 2
0
    public void UnlockAchievement(AchievementID achievementID)
    {
        if (!SteamManager.Initialized && !debugMode)
        {
            return;
        }

        bool achivementFound = false;

        foreach (var a in Achievements)
        {
            if (a.achievementID == achievementID)
            {
                achivementFound = true;

                if (a.achieved)
                {
                    if (debugMode)
                    {
                        Debug.Log("Already unlocked: " + a.achievementID.ToString());
                    }
                    return;
                }

                a.achieved = true;

                LastAchievement();

                if (debugMode)
                {
                    Debug.Log("Unlocked: " + a.achievementID.ToString());
                    return;
                }
                break;
            }
        }

        if (!achivementFound)
        {
            Debug.LogWarning("Achievement Not Found " + achievementID + " !");
            return;
        }

        // mark it down
        SteamUserStats.SetAchievement(achievementID.ToString());

        StartCoroutine(StoreSteamData());
    }