private void ConnectHorizontally(DungeonRoom left, DungeonRoom right) { IntPair boundaries = left.VerticalBoundaries; int exitWidth = left.ExitWidth; boundaries.y -= exitWidth - 1; int randomPos = Random.Range(boundaries.x, boundaries.y); while (randomPos % exitWidth != 1) { randomPos--; } IntPair exitPos = new IntPair(0, randomPos); left.AddExit(Direction.Right, exitPos); right.AddExit(Direction.Left, exitPos); left.SetNeighbourRoom(right, Direction.Right); right.SetNeighbourRoom(left, Direction.Left); }
private void ConnectVertically(DungeonRoom lower, DungeonRoom upper) { IntPair boundaries = lower.HorizontalBoundaries; int exitWidth = lower.ExitWidth; boundaries.y -= exitWidth - 1; int randomPos = Random.Range(boundaries.x, boundaries.y); while (randomPos % exitWidth != 1) { randomPos--; } IntPair exitPos = new IntPair(randomPos, 0); lower.AddExit(Direction.Up, exitPos); upper.AddExit(Direction.Down, exitPos); lower.SetNeighbourRoom(upper, Direction.Up); upper.SetNeighbourRoom(lower, Direction.Down); }