Пример #1
0
        public override Map Generate()
        {
            int   length               = GetTotalLength();
            int   width                = GetTotalWidth();
            float verticalReciprocal   = 1f / vertical;
            float horizontalReciprocal = 1f / horizontal;
            Map   map = new Map(length, width);

            map.Fill(Tile.Wall);
            for (int y = 0; y < width; y++)
            {
                float yShifted = (y - vertical) * verticalReciprocal;
                float yy       = yShifted * yShifted;
                for (int x = 0; x < length; x++)
                {
                    float xShifted = (x - horizontal) * horizontalReciprocal;
                    float xx       = xShifted * xShifted;
                    if (xx + yy < 1)
                    {
                        map[x, y] = Tile.Floor;
                    }
                }
            }
            map = MapBuilder.ApplyBorder(map, BORDER_SIZE);
            return(map);
        }
Пример #2
0
        public override Map Generate()
        {
            Map map = new Map(length, width);

            map = MapBuilder.ApplyBorder(map, BORDER_SIZE);
            return(map);
        }
Пример #3
0
        /// <summary>
        /// Generates a randomized Map object based on the map generator's properties. May take a significant amount of time
        /// for large maps (particularly for width * length > 10e6).
        /// </summary>
        /// <returns>Returns the generated Map object</returns>
        public Map GenerateMap()
        {
            MapBuilder builder = new MapBuilder(map.Length, map.Width, map.SquareSize);

            builder.InitializeRandomFill(map.InitialDensity, map.Seed);
            builder.Smooth();
            builder.RemoveSmallFloorRegions(map.MinFloorSize);
            builder.ConnectFloors(map.FloorExpansion);
            builder.ExpandRegions(map.FloorExpansion);
            builder.RemoveSmallWallRegions(map.MinWallSize);
            builder.ApplyBorder(map.BorderSize);
            return(builder.ToMap());
        }
        public override Map Generate()
        {
            Map map = MapBuilder.InitializeRandomMap(properties.Length, properties.Width, properties.InitialDensity, seed);

            map.TransformBoundary((x, y) => Tile.Wall);
            MapBuilder.Smooth(map);
            MapBuilder.RemoveSmallFloorRegions(map, properties.MinFloorSize);
            MapBuilder.ConnectFloors(map, seed);
            if (properties.ExpandTunnels)
            {
                MapBuilder.WidenTunnels(map);
            }
            MapBuilder.RemoveSmallWallRegions(map, properties.MinWallSize);
            map = MapBuilder.ApplyBorder(map, properties.BorderSize);
            return(map);
        }