private static void fillOutOutputRoomData_checkULCorner(SimpleRoom_Output thisRoom_output, SimpleRoom_Output leftRoom_output, SimpleRoom_Output upRoom_output, SimpleRoom_Output diagonalRoom_output, SimpleRoom_Building thisRoom_building, SimpleRoom_Building leftRoom_building, SimpleRoom_Building upRoom_building, SimpleRoom_Building diagonalRoom_building) { // If any of these rooms are empty, keep the corner closed: if (!thisRoom_output.getIsNotEmpty() || !leftRoom_output.getIsNotEmpty() || !upRoom_output.getIsNotEmpty() || !diagonalRoom_output.getIsNotEmpty()) { return; } // Check all eight walls connected to this corner. If all of them are open, open up the corner: if (thisRoom_output.getWallIsOpen(Constants.doorID_up) && thisRoom_output.getWallIsOpen(Constants.doorID_left) && // leftRoom_output.getWallIsOpen(Constants.doorID_up) && leftRoom_output.getWallIsOpen(Constants.doorID_right) && // upRoom_output.getWallIsOpen(Constants.doorID_down) && upRoom_output.getWallIsOpen(Constants.doorID_left) && diagonalRoom_output.getWallIsOpen(Constants.doorID_down) && diagonalRoom_output.getWallIsOpen(Constants.doorID_right) && (thisRoom_building.getContainsDoor() == Constants.simplified_doorStatus_undefined || thisRoom_building.getPreviousRoomDirection() == Constants.doorID_right || thisRoom_building.getPreviousRoomDirection() == Constants.doorID_down) && (leftRoom_building.getContainsDoor() == Constants.simplified_doorStatus_undefined || leftRoom_building.getPreviousRoomDirection() == Constants.doorID_left || leftRoom_building.getPreviousRoomDirection() == Constants.doorID_down) && (upRoom_building.getContainsDoor() == Constants.simplified_doorStatus_undefined || upRoom_building.getPreviousRoomDirection() == Constants.doorID_up || upRoom_building.getPreviousRoomDirection() == Constants.doorID_right) && (diagonalRoom_building.getContainsDoor() == Constants.simplified_doorStatus_undefined || diagonalRoom_building.getPreviousRoomDirection() == Constants.doorID_up || diagonalRoom_building.getPreviousRoomDirection() == Constants.doorID_left)) { thisRoom_output.setCornerAsOpen(Constants.cornerID_ul); leftRoom_output.setCornerAsOpen(Constants.cornerID_ur); upRoom_output.setCornerAsOpen(Constants.cornerID_dl); diagonalRoom_output.setCornerAsOpen(Constants.cornerID_dr); } }
public void copyDataFromOneToAnother(SimpleRoom_Building otherRoom) { clearanceLevel = otherRoom.getClearanceLevel(); previousRoomDirection = otherRoom.getPreviousRoomDirection(); containsDoor = otherRoom.getContainsDoor(); containsItem = otherRoom.getContainsItem(); isNotEmpty = otherRoom.getIsNotEmpty(); }
private SimpleRoom_Building[,] instantiateRooms_Building(byte widthHeight) { SimpleRoom_Building[,] returnArray = new SimpleRoom_Building[widthHeight, widthHeight]; for (int indexX = 0; indexX < widthHeight; indexX++) { for (int indexY = 0; indexY < widthHeight; indexY++) { returnArray[indexX, indexY] = new SimpleRoom_Building(); } } return(returnArray); }
private static bool buildOnePath(SimplifiedLayoutDataPacket simpleDataPacket, byte lengthOfPath, bool isKeyPath, System.Random random_thread) { byte[] roomCoords = new byte[2]; // X, Y byte[] roomInfo = new byte[2]; // direction, clearance // First, find a good spotm and gather information: do { roomCoords = simpleDataPacket.getRandomCoordInBoundingBox(random_thread); roomInfo = gatherInfoAboutRandomAdjacentPlacedRoom(simpleDataPacket.getSimpleArray_building(), roomCoords, random_thread); } while (roomInfo[0] == Constants.doorID_null); // Reset the path array, update it's position relative to the builderArray, and keep track of the first room: SimpleRoom_Building firstRoomInPath = simpleDataPacket.resetArray_Path(roomCoords[0], roomCoords[1]); // define the first room, which will always have a door on a keyPath: if (isKeyPath) { roomInfo[1] = simpleDataPacket.getCurrentClearanceLevel(); if (lengthOfPath > 1) { firstRoomInPath.setInformation(roomInfo[1], roomInfo[0], roomInfo[1], 0); } else { firstRoomInPath.setInformation(roomInfo[1], roomInfo[0], roomInfo[1], (byte)(roomInfo[1] + 1)); } } else { byte doorClearance = simpleDataPacket.getRandomClearanceLevel(random_thread); roomInfo[1] = (byte)Mathf.Max(doorClearance, roomInfo[1]); firstRoomInPath.setInformation(roomInfo[1], roomInfo[0], doorClearance, 0); } // now, attempt to place the next room. If any room fails, this will return false. If they all succeed, this will return true: if (addNextRoomToPath(simpleDataPacket, roomCoords, roomInfo, (byte)(lengthOfPath - 1), isKeyPath, random_thread)) { simpleDataPacket.joinPathArrayElementsIntoBuildingArray(); return(true); } return(false); }
private static void fillOutOutputRoomData_checkAdjacentDoors(SimpleRoom_Building thisRoom_building, SimpleRoom_Building adjRoom_building, SimpleRoom_Output thisRoom_output, SimpleRoom_Output adjRoom_output, byte thisRoomConnection, byte adjRoomConnection) { // thisRoomConnection should be either Constants.doorID_right or Constants.doorID_down, // while adjRoomConnection should be either Constants.doorID_left or Constants.doorID_up. // If this room has no building entry, keep the output empty as well: if (!thisRoom_building.getIsNotEmpty() || !adjRoom_building.getIsNotEmpty()) { return; } // If the rooms share a clearance level, or if they are connected by a door, open their walls: if (thisRoom_building.getClearanceLevel() == adjRoom_building.getClearanceLevel() || (thisRoom_building.getContainsDoor() != Constants.simplified_doorStatus_undefined && thisRoom_building.getPreviousRoomDirection() == thisRoomConnection) || (adjRoom_building.getContainsDoor() != Constants.simplified_doorStatus_undefined && adjRoom_building.getPreviousRoomDirection() == adjRoomConnection)) { thisRoom_output.setWallAsOpen(thisRoomConnection); adjRoom_output.setWallAsOpen(adjRoomConnection); } // If not, both walls will stay closed. }