Exemple #1
0
        public static UnlockedManager fromXML(XmlElement xmlElement)
        {
            UnlockedManager manager = new UnlockedManager();

            foreach (XmlElement element in xmlElement.GetElementsByTagName("difficultyUnlocked"))
            {
                DifficultyProgress prog = DifficultyProgress.fromXML(element);
                manager.campaignsUnlocked.Add(new Guid(element.GetAttribute("guid")), prog);
            }
            return(manager);
        }
Exemple #2
0
        public void add(MapManager mapManager, DifficultyEnum difficulty)
        {
            if (!campaignsUnlocked.ContainsKey(mapManager.guid))
            {
                campaignsUnlocked.Add(mapManager.guid, new DifficultyProgress());
            }
            DifficultyProgress diffProgress = campaignsUnlocked[mapManager.guid];

            if (!diffProgress.difficultiesUnlocked.ContainsKey(difficulty))
            {
                diffProgress.difficultiesUnlocked.Add(difficulty, new LevelsUnlocked());
            }
            LevelsUnlocked unlocked = diffProgress.difficultiesUnlocked[difficulty];

            if (!unlocked.isUnlocked(mapManager.getCurrentLevelIndex()))
            {
                unlocked.levelsUnlocked.Add(mapManager.getCurrentLevelIndex());
            }
        }
Exemple #3
0
        public static DifficultyProgress fromXML(XmlElement element)
        {
            DifficultyProgress progress = new DifficultyProgress();

            foreach (XmlElement levelsNode in element)
            {
                DifficultyEnum difficulty = (DifficultyEnum)Enum.Parse(typeof(DifficultyEnum), levelsNode.GetAttribute("difficulty"));
                List <int>     levels     = new List <int>();
                foreach (String level in levelsNode.GetAttribute("levels").Split(','))
                {
                    try
                    {
                        levels.Add(int.Parse(level));
                    }
                    catch (Exception e) { System.Console.Write(e.StackTrace); }
                }
                progress.difficultiesUnlocked.Add(difficulty, new LevelsUnlocked(levels));
            }
            return(progress);
        }