private void CheckForUnlock(Achievement.AchievementType selectedType, int inputValue)
 {
     foreach (Achievement ach in achievements)
     {
         if (ach.type == selectedType)
         {
             if (!ach.isUnlocked && inputValue >= ach.valueToUnlock)
             {
                 UnlockAchievement(ach);
             }
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Returns true if the achievement has been successfully given. Includes an Achievement output.
        /// </summary>
        public static bool giveAchievement(string name, bool isItem, Achievement.AchievementType type, out Achievement achievement)
        {
            List <char> encoder = new List <char>();

            foreach (char x in masterEncoder)
            {
                encoder.Add(x);
            }
            achievement = Achievements.empty;
            if (isItem)
            {
                if (listOfAchievements.Where(g => g.linkedItem == name && g.type == type).LongCount() > 0)
                {
                    achievement = listOfAchievements.Where(g => g.linkedItem == name && g.type == type).ToArray()[0];
                    if (!Properties.Settings.Default.achievementList.Contains(encoder[listOfAchievements.ToList().IndexOf(achievement)]))
                    {
                        Properties.Settings.Default.achievementList += encoder[listOfAchievements.ToList().IndexOf(achievement)];
                        return(true);
                    }
                }
            }
            else
            {
                if (listOfAchievements.Where(g => g.name == name && g.type == type).LongCount() > 0)
                {
                    achievement = listOfAchievements.Where(g => g.name == name && g.type == type).ToArray()[0];
                    if (!Properties.Settings.Default.achievementList.Contains(encoder[listOfAchievements.ToList().IndexOf(achievement)]))
                    {
                        Properties.Settings.Default.achievementList += encoder[listOfAchievements.ToList().IndexOf(achievement)];
                        return(true);
                    }
                }
            }
            return(false);

            /*
             * try
             * {
             * }
             * catch (Exception)
             * {
             *  achievement = Achievements.empty;
             *  return false;
             * }
             */
        }
Exemple #3
0
 /// <summary>
 /// Returns true if the achievement has been successfully given.
 /// </summary>
 public static bool giveAchievement(string name, bool isItem, Achievement.AchievementType type)
 {
     return(giveAchievement(name, isItem, type, out Achievement achievement));
 }