public boolean connect( Room room ) { if ((neigbours.contains(room) || addNeigbour(room)) && !connected.containsKey( room ) && canConnect(room)) { connected.put( room, null ); room.connected.put( this, null ); return true; } return false; }
public final ArrayList<Point> charPlaceablePoints(Level l){ ArrayList<Point> points = new ArrayList<>(); for (int i = left; i <= right; i++) { for (int j = top; j <= bottom; j++) { Point p = new Point(i, j); if (canPlaceCharacter(p, l)) points.add(p); } } return points; }
public final ArrayList<Point> grassPlaceablePoints(){ ArrayList<Point> points = new ArrayList<>(); for (int i = left; i <= right; i++) { for (int j = top; j <= bottom; j++) { Point p = new Point(i, j); if (canPlaceGrass(p)) points.add(p); } } return points; }
public int remConnections(int direction){ if (curConnections(ALL) >= maxConnections(ALL)) return 0; else return maxConnections(direction) - curConnections(direction); }
public boolean canConnect( Room r ){ Rect i = intersect( r ); boolean foundPoint = false; for (Point p : i.getPoints()){ if (canConnect(p) && r.canConnect(p)){ foundPoint = true; break; } } if (!foundPoint) return false; if (i.width() == 0 && i.left == left) return canConnect(LEFT) && r.canConnect(LEFT); else if (i.height() == 0 && i.top == top) return canConnect(TOP) && r.canConnect(TOP); else if (i.width() == 0 && i.right == right) return canConnect(RIGHT) && r.canConnect(RIGHT); else if (i.height() == 0 && i.bottom == bottom) return canConnect(BOTTOM) && r.canConnect(BOTTOM); else return false; }
Rect space = findFreeSpace(start, collision, Math.max(next.maxWidth(), next.maxHeight())); if (!next.setSizeWithLimit(space.width()+1, space.height()+1)){ return -1; targetCenter.y = prev.top - (next.height() - 1) / 2f; targetCenter.x = (float) ((targetCenter.y - b) / m); next.setPos(Math.round(targetCenter.x - (next.width() - 1) / 2f), prev.top - (next.height() - 1)); targetCenter.y = prev.bottom + (next.height() - 1) / 2f; targetCenter.x = (float) ((targetCenter.y - b) / m); next.setPos(Math.round(targetCenter.x - (next.width() - 1) / 2f), prev.bottom); targetCenter.x = prev.right + (next.width()-1)/2f; targetCenter.y = (float)(m*targetCenter.x + b); next.setPos( prev.right, Math.round(targetCenter.y - (next.height()-1)/2f)); targetCenter.x = prev.left - (next.width()-1)/2f; targetCenter.y = (float)(m*targetCenter.x + b); next.setPos( prev.left - (next.width() - 1), Math.round(targetCenter.y - (next.height()-1)/2f)); if (next.right < prev.left+2) next.shift(prev.left+2-next.right, 0); else if (next.left > prev.right-2) next.shift(prev.right-2-next.left, 0); if (next.right > space.right) next.shift( space.right - next.right, 0); else if (next.left < space.left) next.shift( space.left - next.left, 0); } else { if (next.bottom < prev.top+2) next.shift(0, prev.top+2-next.bottom); else if (next.top > prev.bottom-2) next.shift(0, prev.bottom-2-next.top);
@Override public int randomRespawnCell() { int count = 0; int cell = -1; while (true) { if (++count > 30) { return -1; } Room room = randomRoom( StandardRoom.class ); if (room == null || room == roomEntrance) { continue; } cell = pointToCell(room.random(1)); if (!heroFOV[cell] && Actor.findChar( cell ) == null && passable[cell] && room.canPlaceCharacter(cellToPoint(cell), this) && cell != exit) { return cell; } } }
int terr; boolean locked = false; for (Point p : r.getPoints()){ terr = level.map[level.pointToCell(p)]; if (terr == Terrain.LOCKED_DOOR || terr == Terrain.BARRICADE){ for (Point p : r.charPlaceablePoints(level)){ cell = level.pointToCell(p); if (level.passable[cell] && !level.visited[cell] && Actor.findChar(cell) == null){
t.clearConnections(); for (Room c : connectingRoomsThisBranch){ c.clearConnections(); rooms.remove(c); r.clearConnections(); for (Room t : connectingRoomsThisBranch){ t.clearConnections(); rooms.remove(t); if (Random.Int(3) <= 1) branchable.add(connectingRoomsThisBranch.get(j)); if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) { if (r instanceof StandardRoom){ for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++){
@Override public boolean canPlaceTrap(Point p) { //traps cannot appear in connection rooms on floor 1 return super.canPlaceTrap(p) && Dungeon.depth > 1; }
public final ArrayList<Point> waterPlaceablePoints(){ ArrayList<Point> points = new ArrayList<>(); for (int i = left; i <= right; i++) { for (int j = top; j <= bottom; j++) { Point p = new Point(i, j); if (canPlaceWater(p)) points.add(p); } } return points; }
protected static void findNeighbours(ArrayList<Room> rooms){ Room[] ra = rooms.toArray( new Room[0] ); for (int i=0; i < ra.length-1; i++) { for (int j=i+1; j < ra.length; j++) { ra[i].addNeigbour( ra[j] ); } } }
Rect space = findFreeSpace(start, collision, Math.max(next.maxWidth(), next.maxHeight())); if (!next.setSizeWithLimit(space.width()+1, space.height()+1)){ return -1; targetCenter.y = prev.top - (next.height() - 1) / 2f; targetCenter.x = (float) ((targetCenter.y - b) / m); next.setPos(Math.round(targetCenter.x - (next.width() - 1) / 2f), prev.top - (next.height() - 1)); targetCenter.y = prev.bottom + (next.height() - 1) / 2f; targetCenter.x = (float) ((targetCenter.y - b) / m); next.setPos(Math.round(targetCenter.x - (next.width() - 1) / 2f), prev.bottom); targetCenter.x = prev.right + (next.width()-1)/2f; targetCenter.y = (float)(m*targetCenter.x + b); next.setPos( prev.right, Math.round(targetCenter.y - (next.height()-1)/2f)); targetCenter.x = prev.left - (next.width()-1)/2f; targetCenter.y = (float)(m*targetCenter.x + b); next.setPos( prev.left - (next.width() - 1), Math.round(targetCenter.y - (next.height()-1)/2f)); if (next.right < prev.left+2) next.shift(prev.left+2-next.right, 0); else if (next.left > prev.right-2) next.shift(prev.right-2-next.left, 0); if (next.right > space.right) next.shift( space.right - next.right, 0); else if (next.left < space.left) next.shift( space.left - next.left, 0); } else { if (next.bottom < prev.top+2) next.shift(0, prev.top+2-next.bottom); else if (next.top > prev.bottom-2) next.shift(0, prev.bottom-2-next.top);
public boolean canConnect( Room r ){ Rect i = intersect( r ); boolean foundPoint = false; for (Point p : i.getPoints()){ if (canConnect(p) && r.canConnect(p)){ foundPoint = true; break; } } if (!foundPoint) return false; if (i.width() == 0 && i.left == left) return canConnect(LEFT) && r.canConnect(LEFT); else if (i.height() == 0 && i.top == top) return canConnect(TOP) && r.canConnect(TOP); else if (i.width() == 0 && i.right == right) return canConnect(RIGHT) && r.canConnect(RIGHT); else if (i.height() == 0 && i.bottom == bottom) return canConnect(BOTTOM) && r.canConnect(BOTTOM); else return false; }
public int remConnections(int direction){ if (curConnections(ALL) >= maxConnections(ALL)) return 0; else return maxConnections(direction) - curConnections(direction); }
@Override public int randomRespawnCell() { int count = 0; int cell = -1; while (true) { if (++count > 30) { return -1; } Room room = randomRoom( StandardRoom.class ); if (room == null || room == roomEntrance) { continue; } cell = pointToCell(room.random(1)); if (!heroFOV[cell] && Actor.findChar( cell ) == null && passable[cell] && room.canPlaceCharacter(cellToPoint(cell), this) && cell != exit) { return cell; } } }
int terr; boolean locked = false; for (Point p : r.getPoints()){ terr = level.map[level.pointToCell(p)]; if (terr == Terrain.LOCKED_DOOR || terr == Terrain.BARRICADE){ for (Point p : r.charPlaceablePoints(level)){ cell = level.pointToCell(p); if (level.passable[cell] && !level.visited[cell] && Actor.findChar(cell) == null){
t.clearConnections(); for (Room c : connectingRoomsThisBranch){ c.clearConnections(); rooms.remove(c); r.clearConnections(); for (Room t : connectingRoomsThisBranch){ t.clearConnections(); rooms.remove(t); if (Random.Int(3) <= 1) branchable.add(connectingRoomsThisBranch.get(j)); if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) { if (r instanceof StandardRoom){ for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++){