예제 #1
0
파일: NBSP.cs 프로젝트: fenixnix/Fractals
 public string PrintBSP(Grid2DInt map)
 {
     foreach (var r in rooms)
     {
         Grid2DPaint.Rect <int>(map, r, 0);
     }
     return(map.Print());
 }
예제 #2
0
파일: DLA2D.cs 프로젝트: fenixnix/Fractals
        public void Step(Grid2DInt grid, Grid2DInt.CorridorType type = Grid2DInt.CorridorType.Ortho)
        {
            //var walkerPos = OutLineGenerate(grid);
            var        walkerPos = RandomGenerate(grid);
            Walker2D   walker    = new Walker2D(walkerPos);
            Vector2Int curPos    = Vector2Int.zero;

            do
            {
                curPos = walker.Step(grid);
            } while(!grid.NextTo(curPos, type, 255));
            Grid2DPaint.Diamond(grid, curPos.x, curPos.y, 2);
            //grid[curPos.x,curPos.y] = 255;
        }
예제 #3
0
파일: NBSP.cs 프로젝트: fenixnix/Fractals
        public static void Division(Grid2DInt map, RectInt rect, int minSideSize = 12, int maxSideSize = 24)
        {
            if (rect.width <= maxSideSize && rect.height <= maxSideSize)
            {
                if (Random.value < 0.5f)
                {
                    Grid2DPaint.Rect(map, RandomSubRect(rect), 0);
                    return;
                }
            }

            if (rect.width <= minSideSize && rect.height <= minSideSize)
            {
                Grid2DPaint.Rect(map, RandomSubRect(rect), 0);
                return;
            }

            bool isVer = Random.value > .5f;

            isVer = (float)rect.width / (float)rect.height > 1.25f;

            int posX = Random.Range(rect.width / 4, rect.width * 3 / 4) + rect.x;
            int posY = Random.Range(rect.height / 4, rect.height * 3 / 4) + rect.y;

            if (isVer)
            {
                //map.SetBlock(posX, rect.Y, 1, rect.H, 0);
                Division(map, new RectInt(rect.x, rect.x, posX - rect.x, rect.height));
                Division(map, new RectInt(posX + 1, rect.y, rect.x + rect.width - posX - 1, rect.height));
            }
            else
            {
                //map.SetBlock(rect.X, posY, rect.W, 1, 0);
                Division(map, new RectInt(rect.x, rect.y, rect.width, posY - rect.y));
                Division(map, new RectInt(rect.x, posY + 1, rect.width, rect.height - posY + rect.y - 1));
            }
        }
예제 #4
0
파일: DLA2D.cs 프로젝트: fenixnix/Fractals
 public void SetSeedPoint(Grid2DInt grid, Vector2Int seed, Walker2D.WalkType type = Walker2D.WalkType.Direction4)
 {
     Grid2DPaint.Diamond(grid, seed.x, seed.y, 2);
     Walker2D.InitMovTab(type);
 }