コード例 #1
0
ファイル: DungeonClass.cs プロジェクト: Xcelled/MabiPale2
        public static DungeonClass LoadDungeonClass(string dungeon_class)
        {
            foreach (var xmlName in new[] { "dungeondb2.xml", "dungeondb.xml", "dungeon_ruin.xml" })
            {
                var dom = XDocument.Load("data/" + xmlName);
                var dungeons = dom.Descendants("dungeon");
                foreach (var dungeon in dungeons)
                {
                    var name = dungeon.Attribute("name").Value;
                    if (name != null && name.ToLower() == dungeon_class.ToLower())
                    {
                        var dungeonClass = new DungeonClass();
                        dungeonClass.Name = dungeon_class;
                        dungeonClass.BaseSeed = (int)dungeon.Attribute("baseseed");
                        var floorsDescs = dungeon.Descendants("floordesc");
                        foreach (var floorDesc in floorsDescs)
                        {
                            var floor = new SDungeonFloor();
                            floor.is_custom_floor = floorDesc.Attribute("custom") == null ? false : true;
                            floor.width = (int)floorDesc.Attribute("width");
                            floor.height = (int)floorDesc.Attribute("height");
                            floor.crit_path_min = (int)floorDesc.Attribute("critpathmin");
                            floor.crit_path_max = (int)floorDesc.Attribute("critpathmax");
                            floor.HasBossRoom = floorDesc.Elements("boss").Count() > 0 ? true : false;
                            floor.branchProbability = (int)floorDesc.Attribute("branch");
                            floor.coverageFactor = (int)floorDesc.Attribute("coverage");
                            dungeonClass.Floors.Add(floor);
                        }
                        return dungeonClass;
                    }
                }
            }

            return null;
        }
コード例 #2
0
        public static DungeonClass LoadDungeonClass(string dungeon_class)
        {
            foreach (var xmlName in new[] { "dungeondb2.xml", "dungeondb.xml", "dungeon_ruin.xml" })
            {
                var dom      = XDocument.Load("data/" + xmlName);
                var dungeons = dom.Descendants("dungeon");
                foreach (var dungeon in dungeons)
                {
                    var name = dungeon.Attribute("name").Value;
                    if (name != null && name.ToLower() == dungeon_class.ToLower())
                    {
                        var dungeonClass = new DungeonClass();
                        dungeonClass.Name     = dungeon_class;
                        dungeonClass.BaseSeed = (int)dungeon.Attribute("baseseed");
                        var floorsDescs = dungeon.Descendants("floordesc");
                        foreach (var floorDesc in floorsDescs)
                        {
                            var floor = new SDungeonFloor();
                            floor.is_custom_floor   = floorDesc.Attribute("custom") == null ? false : true;
                            floor.width             = (int)floorDesc.Attribute("width");
                            floor.height            = (int)floorDesc.Attribute("height");
                            floor.crit_path_min     = (int)floorDesc.Attribute("critpathmin");
                            floor.crit_path_max     = (int)floorDesc.Attribute("critpathmax");
                            floor.HasBossRoom       = floorDesc.Elements("boss").Count() > 0 ? true : false;
                            floor.branchProbability = (int)floorDesc.Attribute("branch");
                            floor.coverageFactor    = (int)floorDesc.Attribute("coverage");
                            dungeonClass.Floors.Add(floor);
                        }
                        return(dungeonClass);
                    }
                }
            }

            return(null);
        }
コード例 #3
0
        public DungeonStructure(string dungeon_class, int instance_id, int item_id, string option, int seed, int floorplan)
        {
            DungeonClass s_dungeon_class = DungeonClass.LoadDungeonClass(dungeon_class);

            this.name      = s_dungeon_class.Name;
            this.seed      = seed;
            this.floorplan = floorplan;
            this.option    = option.ToLower();
            // init random generators
            MT_maze   = new MTRandom(s_dungeon_class.BaseSeed + item_id + floorplan);
            MT_puzzle = new MTRandom(seed);
            //init floors
            floors = new List <DungeonFloorStructure>();
            DungeonFloorStructure prev = null;

            for (int i = 0; i < s_dungeon_class.Floors.Count; i++)
            {
                bool last_floor             = i == s_dungeon_class.Floors.Count - 1;
                DungeonFloorStructure floor = new DungeonFloorStructure(this, s_dungeon_class.GetFloorDesc(i), last_floor, prev);
                prev = floor;
                floors.Add(floor);
            }
        }