public synchronized void updateFog(){ toUpdate.clear(); toUpdate.add(new Rect(0, 0, mapWidth, mapHeight)); }
public static void updateMap() { if (scene != null) { scene.tiles.updated.set(0, 0, Level.WIDTH, Level.HEIGHT); } }
public static void updateMap( int cell ) { if (scene != null) { scene.tiles.updated.union(cell % Level.WIDTH, cell / Level.WIDTH); } }
protected static Rect findFreeSpace(Point start, ArrayList<Room> collision, int maxSize){ Rect space = new Rect(start.x-maxSize, start.y-maxSize, start.x+maxSize, start.y+maxSize); space.set(start.x, start.y, start.x, start.y); return space; wDiff = (space.right - closestRoom.left) * (space.height() + 1); } else if (closestRoom.right <= start.x){ wDiff = (closestRoom.right - space.left) * (space.height() + 1); hDiff = (space.bottom - closestRoom.top) * (space.width() + 1); } else if (closestRoom.bottom <= start.y){ hDiff = (closestRoom.bottom - space.top) * (space.width() + 1);
@Override public void paint(Level level) { Painter.fill( level, this, Terrain.WALL ); Painter.fill( level, this, 1, Terrain.CHASM ); ArrayList<Rect> platforms = new ArrayList<>(); splitPlatforms( new Rect(left+2, top+2, right-2, bottom-2), platforms); for (Rect platform : platforms){ Painter.fill( level, platform.left, platform.top, platform.width()+1, platform.height()+1, Terrain.EMPTY_SP); } for (Door door : connected.values()) { door.set( Door.Type.REGULAR ); Painter.drawInside(level, this, door, 2, Terrain.EMPTY_SP); } }
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 synchronized void updateFog( int cell, int radius ){ Rect update = new Rect( (cell % mapWidth) - radius, (cell / mapWidth) - radius, (cell % mapWidth) - radius + 1 + 2*radius, (cell / mapWidth) - radius + 1 + 2*radius); update.left = Math.max(0, update.left); update.top = Math.max(0, update.top); update.right = Math.min(mapWidth, update.right); update.bottom = Math.min(mapHeight, update.bottom); if (update.isEmpty()) return; updateFog( update ); }
public void fullyClear(){ volume = 0; area.setEmpty(); cur = new int[Dungeon.level.length()]; off = new int[Dungeon.level.length()]; }
@Override protected void emit( int index ) { if (blob.volume <= 0) { return; } if (blob.area.isEmpty()) blob.setupArea(); int[] map = blob.cur; float size = DungeonTilemap.SIZE; int cell; for (int i = blob.area.left; i < blob.area.right; i++) { for (int j = blob.area.top; j < blob.area.bottom; j++) { cell = i + j*Dungeon.level.width(); if (cell < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[cell] && map[cell] > 0) { float x = (i + Random.Float()) * size; float y = (j + Random.Float()) * size; factory.emit(this, index, x, y); } } } } }
@Override public int width() { return super.width()+1; }
@Override public int height() { return super.height()+1; }
public Rect shrink() { return shrink( 1 ); }
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 ); } } }