Exemplo n.º 1
0
 BSP(int x, int y, int w, int h, BSP father)
 {
     this.x = x;
     this.y = y;
     width = w;
     height = h;
     leaf = true;
     level = (byte)(father.level + 1);
     this.father = father;
 }
Exemplo n.º 2
0
 private void GenRoom(BSP bsp)
 {
     if (bsp.Leaf)
     {
         int x = bsp.X+1;
         int y = bsp.Y+1;
         int w = bsp.Width-2;
         int h = bsp.Height-2;
         for (int i = x; i < x + w; i++)
             for (int j = y; j < y + h; j++)
             {
                 tiles[i, j] = true;
             }
     }
     else
     {
         GenRoom(bsp.Left);
         GenRoom(bsp.Right);
     }
 }
Exemplo n.º 3
0
 public Dungeon(int seed)
 {
     rand = new Random(seed);
     rooms = new BSP(0, 0, WIDTH, HEIGHT);
     tiles = new bool[WIDTH, HEIGHT];
 }
Exemplo n.º 4
0
 /// <summary>
 /// Once you have the root node, you can split it into two smaller non-overlapping nodes.
 /// </summary>
 /// <param name="horizontal">If true, the node will be splitted horizontally, else, vertically.</param>
 /// <param name="position">Coordinate of the splitting position.</param>
 public void SplitOnce(bool horizontal, int position)
 {
     if (horizontal)
     {
         ls = new BSP(x, y, position - x, height, this);
         rs = new BSP(position, y, width + x - position, height, this);
     }
     else
     {
         ls = new BSP(x, y, width, position - y, this);
         rs = new BSP(x, position, width, height + y - position, this);
     }
     leaf = false;
     this.horizontal = horizontal;
     this.position = position;
 }