use of com.watabou.pixeldungeon.levels.Room in project pixel-dungeon by watabou.
the class WeakFloorPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.CHASM);
Room.Door door = room.entrance();
door.set(Room.Door.Type.REGULAR);
if (door.x == room.left) {
for (int i = room.top + 1; i < room.bottom; i++) {
drawInside(level, room, new Point(room.left, i), Random.IntRange(1, room.width() - 2), Terrain.EMPTY_SP);
}
} else if (door.x == room.right) {
for (int i = room.top + 1; i < room.bottom; i++) {
drawInside(level, room, new Point(room.right, i), Random.IntRange(1, room.width() - 2), Terrain.EMPTY_SP);
}
} else if (door.y == room.top) {
for (int i = room.left + 1; i < room.right; i++) {
drawInside(level, room, new Point(i, room.top), Random.IntRange(1, room.height() - 2), Terrain.EMPTY_SP);
}
} else if (door.y == room.bottom) {
for (int i = room.left + 1; i < room.right; i++) {
drawInside(level, room, new Point(i, room.bottom), Random.IntRange(1, room.height() - 2), Terrain.EMPTY_SP);
}
}
}
use of com.watabou.pixeldungeon.levels.Room in project pixel-dungeon by watabou.
the class PassagePainter method paint.
public static void paint(Level level, Room room) {
pasWidth = room.width() - 2;
pasHeight = room.height() - 2;
int floor = level.tunnelTile();
ArrayList<Integer> joints = new ArrayList<Integer>();
for (Point door : room.connected.values()) {
joints.add(xy2p(room, door));
}
Collections.sort(joints);
int nJoints = joints.size();
int perimeter = pasWidth * 2 + pasHeight * 2;
int start = 0;
int maxD = joints.get(0) + perimeter - joints.get(nJoints - 1);
for (int i = 1; i < nJoints; i++) {
int d = joints.get(i) - joints.get(i - 1);
if (d > maxD) {
maxD = d;
start = i;
}
}
int end = (start + nJoints - 1) % nJoints;
int p = joints.get(start);
do {
set(level, p2xy(room, p), floor);
p = (p + 1) % perimeter;
} while (p != joints.get(end));
set(level, p2xy(room, p), floor);
for (Room.Door door : room.connected.values()) {
door.set(Room.Door.Type.TUNNEL);
}
}
use of com.watabou.pixeldungeon.levels.Room in project pixel-dungeon by watabou.
the class PitPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.EMPTY);
Room.Door entrance = room.entrance();
entrance.set(Room.Door.Type.LOCKED);
Point well = null;
if (entrance.x == room.left) {
well = new Point(room.right - 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
} else if (entrance.x == room.right) {
well = new Point(room.left + 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
} else if (entrance.y == room.top) {
well = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.bottom - 1);
} else if (entrance.y == room.bottom) {
well = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.top + 1);
}
set(level, well, Terrain.EMPTY_WELL);
int remains = room.random();
while (level.map[remains] == Terrain.EMPTY_WELL) {
remains = room.random();
}
level.drop(new IronKey(), remains).type = Type.SKELETON;
if (Random.Int(5) == 0) {
level.drop(Generator.random(Generator.Category.RING), remains);
} else {
level.drop(Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR)), remains);
}
int n = Random.IntRange(1, 2);
for (int i = 0; i < n; i++) {
level.drop(prize(level), remains);
}
}
use of com.watabou.pixeldungeon.levels.Room in project pixel-dungeon by watabou.
the class ShopPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.EMPTY_SP);
pasWidth = room.width() - 2;
pasHeight = room.height() - 2;
int per = pasWidth * 2 + pasHeight * 2;
Item[] range = range();
int pos = xy2p(room, room.entrance()) + (per - range.length) / 2;
for (int i = 0; i < range.length; i++) {
Point xy = p2xy(room, (pos + per) % per);
int cell = xy.x + xy.y * Level.WIDTH;
if (level.heaps.get(cell) != null) {
do {
cell = room.random();
} while (level.heaps.get(cell) != null);
}
level.drop(range[i], cell).type = Heap.Type.FOR_SALE;
pos++;
}
placeShopkeeper(level, room);
for (Room.Door door : room.connected.values()) {
door.set(Room.Door.Type.REGULAR);
}
}
use of com.watabou.pixeldungeon.levels.Room in project pixel-dungeon by watabou.
the class Chasm method heroFall.
public static void heroFall(int pos) {
jumpConfirmed = false;
Sample.INSTANCE.play(Assets.SND_FALLING);
if (Dungeon.hero.isAlive()) {
Dungeon.hero.interrupt();
InterlevelScene.mode = InterlevelScene.Mode.FALL;
if (Dungeon.level instanceof RegularLevel) {
Room room = ((RegularLevel) Dungeon.level).room(pos);
InterlevelScene.fallIntoPit = room != null && room.type == Room.Type.WEAK_FLOOR;
} else {
InterlevelScene.fallIntoPit = false;
}
Game.switchScene(InterlevelScene.class);
} else {
Dungeon.hero.sprite.visible = false;
}
}
Aggregations