Esempio n. 1
0
        void _calculate_size(SDungeonFloor floor_desc)
        {
            int w = floor_desc.width;
            int h = floor_desc.height;

            if (floor_desc.width < 6)
            {
                w = 6;
            }
            else if (floor_desc.width > 18)
            {
                w = 18;
            }

            if (floor_desc.height < 6)
            {
                h = 6;
            }
            else if (floor_desc.height > 18)
            {
                h = 18;
            }
            var rnd = dungeon_structure.MT_maze.GetUInt32();

            width  = (int)(w - rnd % (int)(w / 5.0));
            rnd    = dungeon_structure.MT_maze.GetUInt32();
            height = (int)(h - rnd % (int)(h / 5.0));
        }
Esempio n. 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;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public DungeonFloorStructure(DungeonStructure dungeon_structure, SDungeonFloor floor_desc, bool isLastFloor, DungeonFloorStructure prev)
 {
     pos = new Position(0, 0);
     start_pos = new Position(0, 0);
     prev_floor_structure = prev;
     this.dungeon_structure = dungeon_structure;
     HasBossRoom = floor_desc.HasBossRoom;
     branchProbability = floor_desc.branchProbability;
     coverageFactor = floor_desc.coverageFactor;
     IsLastFloor = isLastFloor;
     _calculate_size(floor_desc);
     _init_roomtraits();
     maze_generator = new MazeGenerator();
     _generate_maze(floor_desc);
 }
Esempio n. 5
0
 public DungeonFloorStructure(DungeonStructure dungeon_structure, SDungeonFloor floor_desc, bool isLastFloor, DungeonFloorStructure prev)
 {
     pos                    = new Position(0, 0);
     start_pos              = new Position(0, 0);
     prev_floor_structure   = prev;
     this.dungeon_structure = dungeon_structure;
     HasBossRoom            = floor_desc.HasBossRoom;
     branchProbability      = floor_desc.branchProbability;
     coverageFactor         = floor_desc.coverageFactor;
     IsLastFloor            = isLastFloor;
     _calculate_size(floor_desc);
     _init_roomtraits();
     maze_generator = new MazeGenerator();
     _generate_maze(floor_desc);
 }
Esempio n. 6
0
        void _calculate_size(SDungeonFloor floor_desc)
        {
            int w = floor_desc.width;
            int h = floor_desc.height;
            if (floor_desc.width < 6)
                w = 6;
            else if (floor_desc.width > 18)
                w = 18;

            if (floor_desc.height < 6)
                h = 6;
            else if (floor_desc.height > 18)
                h = 18;
            var rnd = dungeon_structure.MT_maze.GetUInt32();
            width = (int)(w - rnd % (int)(w / 5.0));
            rnd = dungeon_structure.MT_maze.GetUInt32();
            height = (int)(h - rnd % (int)(h / 5.0));
        }
Esempio n. 7
0
        void _generate_maze(SDungeonFloor floor_desc)
        {
            int crit_path_min = floor_desc.crit_path_min;
            int crit_path_max = floor_desc.crit_path_max;

            if (crit_path_min < 1)
            {
                crit_path_min = 1;
            }
            if (crit_path_max < 1)
            {
                crit_path_max = 1;
            }
            if (crit_path_min > crit_path_max)
            {
                int temp = crit_path_max;
                crit_path_max = crit_path_min;
                crit_path_min = temp;
            }
            _create_critical_path(crit_path_min, crit_path_max);
            _create_sub_path(coverageFactor, branchProbability);
            _update_path_position();
        }
Esempio n. 8
0
 void _generate_maze(SDungeonFloor floor_desc)
 {
     int crit_path_min = floor_desc.crit_path_min;
     int crit_path_max = floor_desc.crit_path_max;
     if (crit_path_min < 1)
         crit_path_min = 1;
     if (crit_path_max < 1)
         crit_path_max = 1;
     if (crit_path_min > crit_path_max)
     {
         int temp = crit_path_max;
         crit_path_max = crit_path_min;
         crit_path_min = temp;
     }
     _create_critical_path(crit_path_min, crit_path_max);
     _create_sub_path(coverageFactor, branchProbability);
     _update_path_position();
 }