private void Start() { Subdungeon rootSubDungeon = new Subdungeon(new Rect(0, 0, rows, columns)); CreateBSP(rootSubDungeon); rootSubDungeon.CreateRooms(); boardPosFloor = new GameObject[rows, columns]; DrawRooms(rootSubDungeon); DrawCorridors(rootSubDungeon); DrawWalls(); DrawBase(); Vector3 playerPos = new Vector3(rootSubDungeon.GetRoom().xMax / 2, rootSubDungeon.GetRoom().yMax / 2, 0f); //put the player in the middle of the first room player.transform.position = playerPos; //set player position Vector3 center = new Vector3(rows / 2, columns / 2, -1f); //have the minimap render out a top down view of the center of the map minimap.transform.position = center; minimap.orthographicSize = rows / 2f; //keep size large enough that it can see the entire dungeon output playerPos.z = -9f; Darkness.transform.position = playerPos; }
public void CreateRooms() { //Get to a leaf node if (left != null) { left.CreateRooms(); } if (right != null) { right.CreateRooms(); } if (right != null && left != null) { CreateCorridor(left, right); } //if we are on a leaf, create a new room if (isLeaf()) { int roomWidth = (int)Random.Range(rect.width / 2, rect.width - 2); int roomHeight = (int)Random.Range(rect.height / 2, rect.height - 2); int roomX = (int)Random.Range(1, rect.width - roomWidth - 1); int roomY = (int)Random.Range(1, rect.height - roomHeight - 1); room = new Rect(rect.x + roomX, rect.y + roomY, roomWidth, roomHeight); } }