Search in sources :

Example 6 with Room

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);
        }
    }
}
Also used : Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 7 with Room

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);
    }
}
Also used : ArrayList(java.util.ArrayList) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 8 with Room

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);
    }
}
Also used : IronKey(com.watabou.pixeldungeon.items.keys.IronKey) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 9 with Room

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);
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 10 with Room

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;
    }
}
Also used : Room(com.watabou.pixeldungeon.levels.Room) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel)

Aggregations

Room (com.watabou.pixeldungeon.levels.Room)16 Point (com.watabou.utils.Point)11 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)6 Alchemy (com.watabou.pixeldungeon.actors.blobs.Alchemy)1 SacrificialFire (com.watabou.pixeldungeon.actors.blobs.SacrificialFire)1 Piranha (com.watabou.pixeldungeon.actors.mobs.Piranha)1 Statue (com.watabou.pixeldungeon.actors.mobs.Statue)1 Blacksmith (com.watabou.pixeldungeon.actors.mobs.npcs.Blacksmith)1 RatKing (com.watabou.pixeldungeon.actors.mobs.npcs.RatKing)1 Heap (com.watabou.pixeldungeon.items.Heap)1 Item (com.watabou.pixeldungeon.items.Item)1 PotionOfInvisibility (com.watabou.pixeldungeon.items.potions.PotionOfInvisibility)1 PotionOfLevitation (com.watabou.pixeldungeon.items.potions.PotionOfLevitation)1 RegularLevel (com.watabou.pixeldungeon.levels.RegularLevel)1 ArrayList (java.util.ArrayList)1