コード例 #1
0
 public DungeonCorridorMapGenerator(int[] pixelTypes, MapCoordinate
    coordinate, int turnCostPenalty, int[] intoPixelCostPenalty) :
    base(pixelTypes, coordinate)
 {
     this.turnCostPenalty = turnCostPenalty;
     this.intoPixelCostPenalty = intoPixelCostPenalty;
 }
コード例 #2
0
 public BSPBuildingMapGenerator(int[] pixelTypes, MapCoordinate coordinate,
    int nLevels, int corridorWidth, int minimumRoomWidth) :
    base(pixelTypes, coordinate)
 {
     this.nLevels = nLevels;
     this.corridorWidth = corridorWidth;
     this.minimumRoomWidth = minimumRoomWidth;
 }
コード例 #3
0
 public DungeonRoomMapGenerator(int[] pixelTypes, MapCoordinate
    coordinate, int minSide, int maxSide, int openPercentage,
    int maxDoorsPerRoom) :
    base(pixelTypes, coordinate)
 {
     this.minSide = minSide;
     this.maxSide = maxSide;
     this.openPercentage = openPercentage;
     this.maxDoorsPerRoom = maxDoorsPerRoom;
 }
コード例 #4
0
 // pixel types: 
 //    [0] = wall (filled)
 //    [1] = floor (empty)
 // custom params:
 //    seedCorridorAverageSpacing - average x and y distance between
 //       parallel seed corridors
 //    seedCorridorAverageLength - average length of seed corridors;
 //       length from 50% to 150% of that.  Should be somewhat less than
 //       smallest map dim.  Seed corridors are truncated at inviolable
 //       rectangles
 //    numberOfDecays - number of CA decay steps to run
 //    decayPercentPerDecayedNeighbor - chance of a filled square 
 //       decaying to empty = # of decayed neighbors * this percent
 public CADecayMapGenerator(int[] pixelTypes,
    MapCoordinate coordinate,
    int seedCorridorAverageSpacing,
    int seedCorridorAverageLength,
    int numberOfDecays,
    int decayPercentPerDecayedNeighbor) : base(pixelTypes, coordinate)
 {
     this.seedCorridorAverageSpacing = seedCorridorAverageSpacing;
     this.seedCorridorAverageLength = seedCorridorAverageLength;
     this.numberOfDecays = numberOfDecays;
     this.decayPercentPerDecayedNeighbor = decayPercentPerDecayedNeighbor;
 }
コード例 #5
0
 // pixel types: 
 //    [0] = what grows here
 //    [1]..[n] = existing pixel types [0] can grow into
 // custom params:
 //    seedPointInverseDensity - on the first pass, we seed with single
 //       pixels of [0], on average one per this many growable squares
 //    numberOfGrowPasses - number of CA growth steps to run
 //    growthPercentPerGrownNeighbor - chance of an open growable square
 //       switching to [0] = # of [0] neighbors * this percent
 public CAGrowthMapGenerator(int[] pixelTypes,
    MapCoordinate coordinate,
    int seedPointInverseDensity,
    int numberOfGrowPasses,
    int growthPercentPerGrownNeighbor) : base(pixelTypes, coordinate)
 {
     this.newGrowthPixel = pixelTypes[0];
     this.openGrowthPixels = new int[pixelTypes.Length - 1];
     for (int i = 0; i < openGrowthPixels.Length; i++)
     {
         openGrowthPixels[i] = pixelTypes[i + 1];
     }
     this.seedPointInverseDensity = seedPointInverseDensity;
     this.numberOfGrowPasses = numberOfGrowPasses;
     this.growthPercentPerGrownNeighbor = growthPercentPerGrownNeighbor;
 }
コード例 #6
0
        static public void Main()
        {
            //UI d = new VT100UI();
            VT100UI d = new VT100UI();

            // This is just a placeholder

            for (int x = 0; x < 80; x++)
            {
                d.DrawAt(x, 3, " ", 0, 0, 0, 0, 0, 64);
            }

            for (int x = 0; x < 80; x++)
            {
                d.DrawAt(x, 22, " ", 0, 0, 0, 0, 0, 64);
            }

            UIMapElement map_element = d.MapElement(
                x: 0,
                y: 4,
                h: 17
                );

            ClearMapGenerator gen = new ClearMapGenerator(new int[] { 0, 0 },
                                                          MapCoordinate.GenerateRandom());

            map_element.map = new MapData(80, 40);
            ClearMapGenerator gen2 = new ClearMapGenerator(new int[] { 2, 1 },
                                                           MapCoordinate.GenerateRandom());

            gen2.Run(map_element.map.grid, new MapRectangle(10, 10, 10, 10), null);
            List <MapRoom> blockedList = new List <MapRoom>();
            MapRectangle   fullArea    = new MapRectangle(0, 0, 80, 40);

            blockedList.Add(new MapRoom(new MapRectangle(10, 10, 10, 10)));
            gen.Run(map_element.map.grid, fullArea, blockedList);

            DungeonRoomMapGenerator drmg = new DungeonRoomMapGenerator(new int[]
                                                                       { 5, 6, 7 }, MapCoordinate.GenerateRandom(), 5, 12, 10, 3);
            List <MapRoom> allRooms = drmg.Run(map_element.map.grid, fullArea, blockedList);

            DungeonCorridorMapGenerator dcmg = new DungeonCorridorMapGenerator(
                new int[] { 5, 6, 7 }, MapCoordinate.GenerateRandom(), 2,
                new int[] { 0, 100000, 100000, 0, 0, 100000, 0, 0 });

            dcmg.Run(map_element.map.grid, fullArea, allRooms);

            map_element.map.AddSpaceType(glyph: '#', r: 128, g: 128, b: 128);
            map_element.map.AddSpaceType(glyph: '#', r: 128, g: 128, b: 128);
            map_element.map.AddSpaceType(glyph: '#', r: 128, g: 128, b: 128);
            map_element.map.AddSpaceType(glyph: '*');
            map_element.map.AddSpaceType(glyph: '~', r:   0, g:  32, b: 255);
            map_element.map.AddSpaceType(glyph: '#', r: 128, g: 128, b: 128);
            map_element.map.AddSpaceType(glyph: '.', r:  64, g:  64, b:  64);
            map_element.map.AddSpaceType(glyph: '+', r: 128, g:  64, b:   0);

            d.DrawAt(54, 3, " 5 targets in range    ", 255, 255, 192, 0, 0, 0);
            d.DrawAt(74, 3, "[T] ", 192, 192, 255, 0, 0, 0);
            d.DrawAt(58, 22, " Press     for help ", 255, 255, 192, 0, 0, 0);
            d.DrawAt(65, 22, "[?]", 192, 192, 255, 0, 0, 0);

            map_element.Draw();

            d.DrawScreen();
        }
コード例 #7
0
 public MapGenerator(int[] pixelTypes, MapCoordinate coordinate)
 {
     this.pixelTypes = pixelTypes;
     this.coordinate = coordinate;
     this.random     = new Random();
 }
コード例 #8
0
 public ClearMapGenerator(int[] pixelTypes, MapCoordinate coordinate) :
    base(pixelTypes, coordinate)
 {
 }
コード例 #9
0
ファイル: MapGenerator.cs プロジェクト: poorsquinky/thuglib
 public MapGenerator(int[] pixelTypes, MapCoordinate coordinate)
 {
     this.pixelTypes = pixelTypes;
     this.coordinate = coordinate;
     this.random = new Random();
 }
コード例 #10
0
ファイル: MapGenerator.cs プロジェクト: poorsquinky/thuglib
 public static MapCoordinate GenerateRandom()
 {
     MapCoordinate newCoord = new MapCoordinate();
     newCoord.guid = nextGuid++;
     return newCoord;
 }
コード例 #11
0
 public ClearMapGenerator(int[] pixelTypes, MapCoordinate coordinate) :
     base(pixelTypes, coordinate)
 {
 }
コード例 #12
0
        public static int Main(String[] args)
        {
            ClearMapGenerator gen = new ClearMapGenerator(new int[] { 0, 0 },
                                                          MapCoordinate.GenerateRandom());

            MapData           mapdata = new MapData(40, 40);
            ClearMapGenerator gen2    = new ClearMapGenerator(new int[] { 2, 1 },
                                                              MapCoordinate.GenerateRandom());

            gen2.Run(mapdata.grid, new MapRectangle(10, 10, 10, 10), null);
            List <MapRoom> blockedList = new List <MapRoom>();
            MapRectangle   fullArea    = new MapRectangle(0, 0, 40, 40);

            blockedList.Add(new MapRoom(new MapRectangle(10, 10, 10, 10)));
            gen.Run(mapdata.grid, fullArea, blockedList);

            if (args.Length == 0)
            {
                Console.WriteLine("Specify -cave, -dungeon, or -office");
                return(0);
            }
            else if (args[0] == "-office")
            {
                gen.Run(mapdata.grid, fullArea, null);
                BSPBuildingMapGenerator bsp = new BSPBuildingMapGenerator(
                    new int[] { 0, 1, 7 }, MapCoordinate.GenerateRandom(),
                    4, 3, 2);
                MapRectangle borderedArea = new MapRectangle(1, 1, 38, 38);
                bsp.Run(mapdata.grid, borderedArea, null);

                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '.');
                mapdata.AddSpaceType(glyph: 'O');
                mapdata.AddSpaceType(glyph: '*');
                mapdata.AddSpaceType(glyph: '~');
                mapdata.AddSpaceType(glyph: 'X');
                mapdata.AddSpaceType(glyph: ' ');
                mapdata.AddSpaceType(glyph: '+');
            }
            else if (args[0] == "-dungeon")
            {
                DungeonRoomMapGenerator drmg = new DungeonRoomMapGenerator(new
                                                                           int[] { 5, 6, 7 }, MapCoordinate.GenerateRandom(),
                                                                           5, 12, 10, 3);
                List <MapRoom> allRooms = drmg.Run(mapdata.grid, fullArea,
                                                   blockedList);
                DungeonCorridorMapGenerator dcmg = new
                                                   DungeonCorridorMapGenerator(
                    new int[] { 5, 6, 7 }, MapCoordinate.GenerateRandom(), 2,
                    new int[] { 0, 100000, 100000, 0, 0, 100000, 0, 0 });
                dcmg.Run(mapdata.grid, fullArea, allRooms);

                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '*');
                mapdata.AddSpaceType(glyph: '~');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: ' ');
                mapdata.AddSpaceType(glyph: '+');
            }
            else if (args[0] == "-cave")
            {
                CADecayMapGenerator cad = new CADecayMapGenerator(new
                                                                  int[] { 0, 1 }, MapCoordinate.GenerateRandom(), 10, 20, 5, 10);
                // add this to not get random caves
                // cad.UseCoordinateBasedRandom();
                cad.Run(mapdata.grid, fullArea, blockedList);
                CAGrowthMapGenerator cag1 = new CAGrowthMapGenerator(new int[]
                                                                     { 3, 1 }, MapCoordinate.GenerateRandom(), 50, 2, 20);
                cag1.Run(mapdata.grid, fullArea, blockedList);
                CAGrowthMapGenerator cag2 = new CAGrowthMapGenerator(new int[]
                                                                     { 4, 1, 2 }, MapCoordinate.GenerateRandom(), 200, 8, 20);
                cag2.Run(mapdata.grid, fullArea, blockedList);
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '.');
                mapdata.AddSpaceType(glyph: 'O');
                mapdata.AddSpaceType(glyph: '*');
                mapdata.AddSpaceType(glyph: '~');
                mapdata.AddSpaceType(glyph: 'X');
                mapdata.AddSpaceType(glyph: ' ');
                mapdata.AddSpaceType(glyph: '+');
            }
            else if (args[0] == "-line")
            {
                Path path = PathUtils.GetBresenhamPath(0, 1, 6, 4, null);
                Console.WriteLine("Path from 0, 1 to 6, 4");
                PathUtils.PrintPath(path, 0, 1);
                PathUtils.GetBresenhamPath(-3, 1, -4, 9, path);
                Console.WriteLine("Path from -3, 1 to -4, 9");
                PathUtils.PrintPath(path, -3, 1);

                gen = new ClearMapGenerator(new int[] { 1, 1 },
                                            MapCoordinate.GenerateRandom());
                fullArea = new MapRectangle(0, 0, 40, 40);
                mapdata  = new MapData(40, 40);
                gen.Run(mapdata.grid, fullArea, null);
                int length = PathUtils.CalculateBresenhamProductSquareToSquare(
                    0, 1, 6, 4, mapdata.grid, (x, y) => x + y, 0);
                Console.WriteLine("Length (0, 1) -> (6, 4) in steps = " + length);

                MapData distance = new MapData(40, 40);
                PathUtils.CalculateBresenhamProductsToRectangle(5, 5, mapdata.grid,
                                                                fullArea, (x, y) => x + y, 0, distance.grid);
                for (int i = 0; i < 20; i++)
                {
                    Console.WriteLine("3 " + i + " dist = " + distance.grid[3][i]);
                }
                return(0);
            }
            else if (args[0] == "-bfs")
            {
                DungeonRoomMapGenerator drmg = new DungeonRoomMapGenerator(new
                                                                           int[] { 5, 6, 7 }, MapCoordinate.GenerateRandom(),
                                                                           5, 12, 10, 3);
                List <MapRoom> allRooms = drmg.Run(mapdata.grid, fullArea,
                                                   blockedList);
                DungeonCorridorMapGenerator dcmg = new
                                                   DungeonCorridorMapGenerator(
                    new int[] { 5, 6, 7 }, MapCoordinate.GenerateRandom(), 2,
                    new int[] { 0, 100000, 100000, 0, 0, 100000, 0, 0 });
                dcmg.Run(mapdata.grid, fullArea, allRooms);

                int  xStart = allRooms[0].bounds.xCenter;
                int  yStart = allRooms[0].bounds.yCenter;
                int  xEnd   = allRooms[1].bounds.xCenter;
                int  yEnd   = allRooms[1].bounds.yCenter;
                Path path   = PathUtils.BFSPath(xStart, yStart, xEnd, yEnd, null,
                                                (x, y) => (mapdata.grid[x][y] >= 6), null, (x, y, d) =>
                                                ((((int)d) % 2) == 1 ? 140 : 100), fullArea);
                if (path != null)
                {
                    int[][] pathSquares = PathUtils.UnrollPath(path, xStart, yStart);
                    for (int i = 0; i < pathSquares.Length; i++)
                    {
                        mapdata.grid[pathSquares[i][0]][pathSquares[i][1]] = 8;
                    }
                }
                mapdata.grid[xStart][yStart] = 9;
                mapdata.grid[xEnd][yEnd]     = 10;

                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: '*');
                mapdata.AddSpaceType(glyph: '~');
                mapdata.AddSpaceType(glyph: '#');
                mapdata.AddSpaceType(glyph: ' ');
                mapdata.AddSpaceType(glyph: '+');
                mapdata.AddSpaceType(glyph: 'v');
                mapdata.AddSpaceType(glyph: 'S');
                mapdata.AddSpaceType(glyph: 'E');
            }
            else
            {
                Console.WriteLine("Specify -cave, -dungeon, or -office");
                return(0);
            }
            DisplayMap(mapdata);
            return(0);
        }