protected void ConvertTileIntersections(VirtualMap map, VirtualCell conversion_cell) { if (conversion_cell.IsEmpty()) { // Empty passages should be filled with floors, unless removable (and thus become rock) if (map.IsPassageRemovable(conversion_cell.location)) { conversion_cell.Type = VirtualCell.CellType.Rock; } else { if (CheckRoom(map, conversion_cell.location)) { AddToCorrectRoom(map, conversion_cell.location); conversion_cell.Type = VirtualCell.CellType.RoomFloor; } else { conversion_cell.Type = VirtualCell.CellType.CorridorFloor; } } } else { // 'None' cells will remain as such, since they will be converted to columns later (or to floors), if needed. } }
protected bool CheckWallRendering(VirtualMap map, VirtualCell conversion_cell) { // Check wheter we need to show a wall or not for this type of map if (conversion_cell.Type == VirtualCell.CellType.EmptyPassage) { return(false); } if (behaviour.usePerimeter && conversion_cell.Type == VirtualCell.CellType.PerimeterWall) { return(true); } //Debug.Log("Check rendering of wall " + conversion_cell.location); if (map.IsPassageRemovable(conversion_cell.location)) { //Debug.Log("NO RENDER"); // Do not render this wall! conversion_cell.Type = VirtualCell.CellType.EmptyPassage; return(false); } else { // This wall must be rendered! return(true); } /* * // We check the neighbours. A rendered wall needs at least one floor nearby. * CellLocation[] floor_neighs = map.GetAllNeighbours(conversion_cell.starting_location); * int countFloorNeighs = 0; * for(int n_i=0; n_i<floor_neighs.Length; n_i++){ * CellLocation other_l = floor_neighs[n_i]; * if (!map.LocationIsOutsideBounds(other_l) && map.GetCell(other_l).IsFloor()){ * countFloorNeighs++; * } * } * if (countFloorNeighs > 0){ * // This wall must be rendered! * return true; * } else { * // Do not render this wall! * conversion_cell.Type = VirtualCell.CellType.EmptyPassage; * return false; * }*/ }
public void ConvertDirectionalRoomColumn(VirtualMap map, VirtualCell conversion_cell) { CellLocation l = conversion_cell.location; if (behaviour.useDirectionalFloors) { CellLocation[] border_neighs; bool considerDoorsAsWalls = true; // Count how many border neighbours are room walls int countWallNeighs = 0; bool[] validIndices = new bool[4]; // This was a 'tile', check neigh walls border_neighs = map.GetAllNeighbours(l); for (int i = 0; i < border_neighs.Length; i++) { CellLocation other_l = border_neighs[i]; if (!map.LocationIsOutsideBounds(other_l) && (((behaviour.isolateDirectionalWallsForRooms && map.GetCell(other_l).IsRoomWall()) || (!behaviour.isolateDirectionalWallsForRooms && map.GetCell(other_l).IsWall())) || (considerDoorsAsWalls && map.GetCell(other_l).IsDoor())) && !map.IsPassageRemovable(other_l) // Make sure the wall is not being removed! ) { //Debug.Log(l + " - " + other_l + " " + map.GetCell(other_l).Type); countWallNeighs++; validIndices[i] = true; } } // Define the adbvanced tiles //Debug.Log ("Cell " + l + " has neigh walls " + countWallNeighs); if (countWallNeighs == 0) { conversion_cell.Type = VirtualCell.CellType.RoomWallO; } else if (countWallNeighs == 1) { conversion_cell.Type = VirtualCell.CellType.RoomWallU; } else if (countWallNeighs == 2) { // Wall I conversion_cell.Type = VirtualCell.CellType.RoomWallI; //Debug.Log("SETTING " + l + " TO I"); for (int i = 0; i < 4; i++) { if (validIndices[i]) { conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 1, 4)]; break; } } // Wall L for (int i = 0; i < 4; i++) { if (validIndices[i] && validIndices[(int)Mathf.Repeat(i + 1, 4)]) { // This and the next are valid: left turn (we consider all of them to be left turns( conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 3, 4)]; conversion_cell.Type = VirtualCell.CellType.RoomWallL; break; } } } else if (countWallNeighs == 3) { conversion_cell.Type = VirtualCell.CellType.RoomWallT; for (int i = 0; i < 4; i++) { if (validIndices[(int)Mathf.Repeat(i - 1, 4)] && validIndices[i] && validIndices[(int)Mathf.Repeat(i + 1, 4)]) { conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 1, 4)]; break; } } } else if (countWallNeighs == 4) { conversion_cell.Type = VirtualCell.CellType.RoomWallX; } } }
public void ConvertDirectionalCorridorColumn(VirtualMap map, VirtualCell conversion_cell) { CellLocation l = conversion_cell.location; if (behaviour.useDirectionalFloors) { // Count how many border neighbours are walls int countWallNeighs = 0; bool[] validIndices = new bool[4]; // This was a 'tile', check neigh walls CellLocation[] border_neighs = map.GetAllNeighbours(l); for (int i = 0; i < border_neighs.Length; i++) { CellLocation other_l = border_neighs[i]; if (!map.LocationIsOutsideBounds(other_l) // && other_l.isValid() ) // TODO: Maybe isValid is not needed! { VirtualCell other_cell = map.GetCell(other_l); if (other_cell.IsWall() && !map.IsPassageRemovable(other_cell.location)) { countWallNeighs++; validIndices[i] = true; } } } // Define the advanced tile to use // TODO: merge this with the one for directional floors somehow! if (countWallNeighs == 0) { conversion_cell.Type = VirtualCell.CellType.CorridorWallO; } else if (countWallNeighs == 1) { conversion_cell.Type = VirtualCell.CellType.CorridorWallU; for (int i = 0; i < 4; i++) { if (validIndices[i]) { conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 3, 4)]; break; } } } else if (countWallNeighs == 2) { // Corridor I conversion_cell.Type = VirtualCell.CellType.CorridorWallI; for (int i = 0; i < 4; i++) { if (validIndices[i]) { conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 1, 4)]; break; } } // Corridor L for (int i = 0; i < 4; i++) { if (validIndices[i] && validIndices[(int)Mathf.Repeat(i + 1, 4)]) { // This and the next are valid: left turn (we consider all of them to be left turns( conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 3, 4)]; conversion_cell.Type = VirtualCell.CellType.CorridorWallL; break; } } } else if (countWallNeighs == 3) { conversion_cell.Type = VirtualCell.CellType.CorridorWallT; for (int i = 0; i < 4; i++) { if (validIndices[(int)Mathf.Repeat(i - 1, 4)] && validIndices[i] && validIndices[(int)Mathf.Repeat(i + 1, 4)]) { // This, the one before and the next are valid: T cross (with this being the middle road) conversion_cell.Orientation = map.directions[(int)Mathf.Repeat(i + 1, 4)]; break; } } } else if (countWallNeighs == 4) { conversion_cell.Type = VirtualCell.CellType.CorridorWallX; } } }