コード例 #1
0
 /// <summary>
 /// Add default achievements if not exist in the database
 /// </summary>
 /// <returns>The achievements.</returns>
 /// <created>Stef</created>
 public List<Achievement> AddAchievements()
 {
     List<Achievement> achievementList = new List<Achievement>();
     Achievement ach2 = new Achievement();
     ach2.countToUnlock = 1000;
     ach2.count = 0;
     ach2.isUnlocked = false;
     ach2.message = "Score over 1000.";
     ach2.description = "Achieve a score over 1000.";
     ach2.achievementType = EAchievementType.Score1000;
     achievementList.Add(ach2);
     Achievement ach3 = new Achievement();
     ach3.countToUnlock = 10000;
     ach3.count = 0;
     ach3.isUnlocked = false;
     ach3.message = "Score over 10000";
     ach3.description = "Achieve a score over 10000.";
     ach3.achievementType = EAchievementType.Score10000;
     achievementList.Add(ach3);
     Achievement ach4 = new Achievement();
     ach4.countToUnlock = 1;
     ach4.count = 0;
     ach4.isUnlocked = false;
     ach4.message = "First level completed.";
     ach4.description = "Complete your first level in any difficulty.";
     ach4.achievementType = EAchievementType.FirstLevelCompleted;
     achievementList.Add(ach4);
     Achievement ach5 = new Achievement();
     ach5.countToUnlock = 1;
     ach5.count = 0;
     ach5.isUnlocked = false;
     ach5.message = "You discovered Python.";
     ach5.description = "Start a level with the Python language.";
     ach5.achievementType = EAchievementType.StartPython;
     achievementList.Add(ach5);
     Achievement ach1 = new Achievement();
     ach1.countToUnlock = 1;
     ach1.count = 0;
     ach1.isUnlocked = false;
     ach1.message = "You discovered Pascal.";
     ach1.description = "Start a level with the Pascal language.";
     ach1.achievementType = EAchievementType.StartPascal;
     achievementList.Add(ach1);
     return achievementList;
 }
コード例 #2
0
 public AchievementEventArgs(Achievement a)
 {
     data = a;
 }
コード例 #3
0
        /// <summary>
        /// Raises the achievement unlocked.
        /// </summary>
        /// <param name="ach">Ach.</param>
        /// <created>Stef</created>
        protected virtual void RaiseAchievementUnlocked(Achievement ach)
        {
            if (!ach.isUnlocked)
            {
                // unlock the event
                ach.isUnlocked = true;

                achievementDatabase.Update(ach);

                var del = AchievementUnlocked as EventHandler;
                if (del != null)
                {
                    del(this, new AchievementEventArgs(ach));
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Checks if the achievement has to be thrown
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="achDatabase">Ach database.</param>
 /// <created>Stef</created>
 public void ParseAchievements(EAchievementType type, Achievement achDatabase)
 {
     if (type == EAchievementType.Score1000)
     {
         if (achDatabase.count >= achDatabase.countToUnlock) RaiseAchievementUnlocked(achDatabase);
     }
     else if (type == EAchievementType.Score10000)
     {
         if (achDatabase.count >= achDatabase.countToUnlock) RaiseAchievementUnlocked(achDatabase);
     }
     else if (achDatabase.count == achDatabase.countToUnlock)
     {
         RaiseAchievementUnlocked(achDatabase);
     }
 }