// Returns true if this passage cell can be removed from the map (i.e. not shown) public bool IsPassageRemovable(CellLocation l) { VirtualCell cell = this.GetCell(l); if (cell.IsWall() || cell.IsEmpty()) { // We count how many valid neighs are floors, and how many are nones int validNeigh = 0; int floorCount = 0; int noneCount = 0; CellLocation n; foreach (DirectionType dir in directions) { n = GetNeighbourCellLocation(l, dir); if (!LocationIsOutsideBounds(n)) { validNeigh++; VirtualCell neigh_cell = GetCell(n); if (neigh_cell.IsFloor()) { floorCount++; } else if (neigh_cell.IsNone() || neigh_cell.IsRock()) { noneCount++; } } } //Debug.Log(l + " Valid neighs: " + validNeigh + " floorCount: " + floorCount + " noneCount: " + noneCount); return(floorCount == 0); } return(false); }
// Various protected void ConvertWallOrientation(VirtualMap map, VirtualCell conversion_cell) { // Fix orientation of walls so that they follow the floors orientation conversion_cell.Orientation = VirtualMap.DirectionType.North; CellLocation neigh_loc = map.GetNeighbourCellLocation(conversion_cell.location, VirtualMap.DirectionType.North); if (!map.LocationIsOutsideBounds(neigh_loc)) { VirtualCell neigh_cell = map.GetCell(neigh_loc); if (neigh_cell.IsNone()) { conversion_cell.Orientation = VirtualMap.DirectionType.East; } } }
// Returns true if this 'none' (i.e. column) cell can be removed from the map (i.e. not shown) public bool IsColumnRemovable(CellLocation l, bool drawCorners = true, bool createColumnsInRooms = false) { VirtualCell cell = this.GetCell(l); if (cell.IsNone()) // Should be performed only on a NONE { int validNeigh = 0; int wallCount = 0; int emptyCount = 0; CellLocation n; foreach (DirectionType dir in directions) { n = GetNeighbourCellLocation(l, dir); if (!LocationIsOutsideBounds(n)) { validNeigh++; VirtualCell neigh_cell = GetCell(n); //Debug.Log(neigh_cell.Type); if (neigh_cell.IsEmpty() || neigh_cell.IsRock()) { emptyCount++; } else { wallCount++; // HACK: we need to do this or the columns won't know if the walls have been made removable during this step! if (IsPassageRemovable(n)) { wallCount--; emptyCount++; } } //Debug.Log("Neigh " + n + " is " + GetCell(n).Type); } } //Debug.Log("Cell " + l + " W " + wallCount + " , E " + emptyCount + " , V " + validNeigh); if (!drawCorners) { // We do not draw corners of rooms (corner = two walls and adjacent) if (wallCount == 2) { // We check whether the two walls are adjacent (also doors) // At least one neigh wall need not be removable as well for this to be a corner (and not an isolated None cell) bool lastWasWall = false; foreach (DirectionType dir in directions) { n = GetNeighbourCellLocation(l, dir); //Debug.Log(n); if (!LocationIsOutsideBounds(n) && (GetCell(n).IsWall() || GetCell(n).IsDoor())) { //Debug.Log("WALL!"); if (lastWasWall) { return(true); // Adjacent! } lastWasWall = true; } else { lastWasWall = false; } } } } // HACK: check if we are in a room (as in the standardmap a roomcolumn is in fact surrounded by empties!) if (IsInRoom(l) && createColumnsInRooms) { return(false); } return(wallCount == 0); } return(false); }