public boolean addNeigbour( Room other ) { if (neigbours.contains(other)) return true; Rect i = intersect( other ); if ((i.width() == 0 && i.height() >= 2) || (i.height() == 0 && i.width() >= 2)) { neigbours.add( other ); other.neigbours.add( this ); return true; } return false; }
public boolean addNeigbour( Room other ) { if (neigbours.contains(other)) return true; Rect i = intersect( other ); if ((i.width() == 0 && i.height() >= 2) || (i.height() == 0 && i.width() >= 2)) { neigbours.add( other ); other.neigbours.add( this ); return true; } return false; }
private void placeDoors( Room r ) { for (Room n : r.connected.keySet()) { Room.Door door = r.connected.get( n ); if (door == null) { Rect i = r.intersect( n ); ArrayList<Point> doorSpots = new ArrayList<>(); for (Point p : i.getPoints()){ if (r.canConnect(p) && n.canConnect(p)) doorSpots.add(p); } if (doorSpots.isEmpty()){ ShatteredPixelDungeon.reportException( new RuntimeException("Could not place a door! " + "r=" + r.getClass().getSimpleName() + " n=" + n.getClass().getSimpleName())); continue; } door = new Room.Door(Random.element(doorSpots)); r.connected.put( n, door ); n.connected.put( r, door ); } } }
private void placeDoors( Room r ) { for (Room n : r.connected.keySet()) { Room.Door door = r.connected.get( n ); if (door == null) { Rect i = r.intersect( n ); ArrayList<Point> doorSpots = new ArrayList<>(); for (Point p : i.getPoints()){ if (r.canConnect(p) && n.canConnect(p)) doorSpots.add(p); } if (doorSpots.isEmpty()){ ShatteredPixelDungeon.reportException( new RuntimeException("Could not place a door! " + "r=" + r.getClass().getSimpleName() + " n=" + n.getClass().getSimpleName())); continue; } door = new Room.Door(Random.element(doorSpots)); r.connected.put( n, door ); n.connected.put( r, door ); } } }
public int curConnections(int direction){ if (direction == ALL) { return connected.size(); } else { int total = 0; for (Room r : connected.keySet()){ Rect i = intersect( r ); if (direction == LEFT && i.width() == 0 && i.left == left) total++; else if (direction == TOP && i.height() == 0 && i.top == top) total++; else if (direction == RIGHT && i.width() == 0 && i.right == right) total++; else if (direction == BOTTOM && i.height() == 0 && i.bottom == bottom) total++; } return total; } }
public int curConnections(int direction){ if (direction == ALL) { return connected.size(); } else { int total = 0; for (Room r : connected.keySet()){ Rect i = intersect( r ); if (direction == LEFT && i.width() == 0 && i.left == left) total++; else if (direction == TOP && i.height() == 0 && i.top == top) total++; else if (direction == RIGHT && i.width() == 0 && i.right == right) total++; else if (direction == BOTTOM && i.height() == 0 && i.bottom == bottom) total++; } return total; } }
Rect w = r.intersect( n ); if (w.left == w.right) {
Rect w = r.intersect( n ); if (w.left == w.right) {
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; }
for (Room n : r.neigbours) { if (n instanceof EmptyRoom && !r.connected.containsKey( n )) { Rect i = r.intersect( n ); if (i.left == i.right && i.bottom - i.top >= 5) {
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; }
for (Room n : r.neigbours) { if (n instanceof EmptyRoom && !r.connected.containsKey( n )) { Rect i = r.intersect( n ); if (i.left == i.right && i.bottom - i.top >= 5) {