void Spawn() { if (!spawned) { spawned = true; if (openingDirection == 1) { rand = Random.Range(0, templates.bottomRooms.Length); Instantiate(templates.bottomRooms[rand], transform.position, templates.bottomRooms[rand].transform.rotation, table.transform); roomControl.AddRoom(); } else if (openingDirection == 2) { rand = Random.Range(0, templates.topRooms.Length); Instantiate(templates.topRooms[rand], transform.position, templates.topRooms[rand].transform.rotation, table.transform); roomControl.AddRoom(); } else if (openingDirection == 3) { rand = Random.Range(0, templates.rightRooms.Length); Instantiate(templates.rightRooms[rand], transform.position, templates.rightRooms[rand].transform.rotation, table.transform); roomControl.AddRoom(); } else if (openingDirection == 4) { rand = Random.Range(0, templates.leftRooms.Length); Instantiate(templates.leftRooms[rand], transform.position, templates.leftRooms[rand].transform.rotation, table.transform); roomControl.AddRoom(); } } }
void Roomie() { for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { if (grid[x, y] == 2) { bool[] door = new bool[5]; if (grid[x + 1, y] != 0) { door[1] = true; } if (grid[x, y - 1] != 0) { door[2] = true; } if (grid[x - 1, y] != 0) { door[3] = true; } if (grid[x, y + 1] != 0) { door[4] = true; } rContr.AddRoom(x, y, door); } } } }