コード例 #1
0
        } //Constructor

        public override MapGenerator.MapData Generate(MapGenerator.RoomsDataCollection rooms, int mapWidth, int mapHeight)
        {
            // Make sure there are rooms and there is map data, if not then ... return failure.
            if (rooms == null || rooms.Count == 0 || mapWidth <= 0 || mapHeight <= 0)
            {
                return(null);
            }

            // Resize the map to what we need.
            MapGenerator.MapData results = new MapGenerator.MapData(mapWidth, mapHeight);

            // Create the instance to the randomizer.
            MapHelpers.SetRandomSeed(this.Options.Seed);

            // (Step 1) Place the initial rooms to start out with.
            MapHelpers.PlotRandomRooms(results, rooms, MapHelpers.ComputeRandomRoomsCount(mapWidth, mapHeight, this.Options.RandomRoomsPercentage), this.Options.IgnoreBoundries, this.Options.SubsetID, this.Options.IncludeRooms, !this.Options.IncludeRooms, this.Options.Pattern, true);

            // (Step 2) Create the passages to connect each room together.
            MapHelpers.ConnectPathsets(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID);

            // (Step 3) if(there is any left over path sets, remove them.
            //MapHelpers.RemoveAllSmallPathSets(results)

            // Remove the map data.
            return(results);
        } //Generate