Search in sources :

Example 11 with Point

use of com.watabou.utils.Point 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 12 with Point

use of com.watabou.utils.Point in project pixel-dungeon by watabou.

the class PrisonBossLevel method decorate.

@Override
protected void decorate() {
    for (int i = WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
        if (map[i] == Terrain.EMPTY) {
            float c = 0.15f;
            if (map[i + 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
                c += 0.2f;
            }
            if (map[i - 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
                c += 0.2f;
            }
            if (map[i + 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
                c += 0.2f;
            }
            if (map[i - 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
                c += 0.2f;
            }
            if (Random.Float() < c) {
                map[i] = Terrain.EMPTY_DECO;
            }
        }
    }
    for (int i = 0; i < WIDTH; i++) {
        if (map[i] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(4) == 0) {
            map[i] = Terrain.WALL_DECO;
        }
    }
    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
        if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(2) == 0) {
            map[i] = Terrain.WALL_DECO;
        }
    }
    while (true) {
        int pos = roomEntrance.random();
        if (pos != entrance) {
            map[pos] = Terrain.SIGN;
            break;
        }
    }
    Point door = roomExit.entrance();
    arenaDoor = door.x + door.y * WIDTH;
    Painter.set(this, arenaDoor, Terrain.LOCKED_DOOR);
    Painter.fill(this, roomExit.left + 2, roomExit.top + 2, roomExit.width() - 3, roomExit.height() - 3, Terrain.INACTIVE_TRAP);
}
Also used : Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 13 with Point

use of com.watabou.utils.Point in project pixel-dungeon by watabou.

the class StatuePainter method paint.

public static void paint(Level level, Room room) {
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Terrain.EMPTY);
    Point c = room.center();
    int cx = c.x;
    int cy = c.y;
    Room.Door door = room.entrance();
    door.set(Room.Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey());
    if (door.x == room.left) {
        fill(level, room.right - 1, room.top + 1, 1, room.height() - 1, Terrain.STATUE);
        cx = room.right - 2;
    } else if (door.x == room.right) {
        fill(level, room.left + 1, room.top + 1, 1, room.height() - 1, Terrain.STATUE);
        cx = room.left + 2;
    } else if (door.y == room.top) {
        fill(level, room.left + 1, room.bottom - 1, room.width() - 1, 1, Terrain.STATUE);
        cy = room.bottom - 2;
    } else if (door.y == room.bottom) {
        fill(level, room.left + 1, room.top + 1, room.width() - 1, 1, Terrain.STATUE);
        cy = room.top + 2;
    }
    Statue statue = new Statue();
    statue.pos = cx + cy * Level.WIDTH;
    level.mobs.add(statue);
    Actor.occupyCell(statue);
}
Also used : Statue(com.watabou.pixeldungeon.actors.mobs.Statue) IronKey(com.watabou.pixeldungeon.items.keys.IronKey) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 14 with Point

use of com.watabou.utils.Point in project pixel-dungeon by watabou.

the class TunnelPainter method paint.

public static void paint(Level level, Room room) {
    int floor = level.tunnelTile();
    Point c = room.center();
    if (room.width() > room.height() || (room.width() == room.height() && Random.Int(2) == 0)) {
        int from = room.right - 1;
        int to = room.left + 1;
        for (Room.Door door : room.connected.values()) {
            int step = door.y < c.y ? +1 : -1;
            if (door.x == room.left) {
                from = room.left + 1;
                for (int i = door.y; i != c.y; i += step) {
                    set(level, from, i, floor);
                }
            } else if (door.x == room.right) {
                to = room.right - 1;
                for (int i = door.y; i != c.y; i += step) {
                    set(level, to, i, floor);
                }
            } else {
                if (door.x < from) {
                    from = door.x;
                }
                if (door.x > to) {
                    to = door.x;
                }
                for (int i = door.y + step; i != c.y; i += step) {
                    set(level, door.x, i, floor);
                }
            }
        }
        for (int i = from; i <= to; i++) {
            set(level, i, c.y, floor);
        }
    } else {
        int from = room.bottom - 1;
        int to = room.top + 1;
        for (Room.Door door : room.connected.values()) {
            int step = door.x < c.x ? +1 : -1;
            if (door.y == room.top) {
                from = room.top + 1;
                for (int i = door.x; i != c.x; i += step) {
                    set(level, i, from, floor);
                }
            } else if (door.y == room.bottom) {
                to = room.bottom - 1;
                for (int i = door.x; i != c.x; i += step) {
                    set(level, i, to, floor);
                }
            } else {
                if (door.y < from) {
                    from = door.y;
                }
                if (door.y > to) {
                    to = door.y;
                }
                for (int i = door.x + step; i != c.x; i += step) {
                    set(level, i, door.y, floor);
                }
            }
        }
        for (int i = from; i <= to; i++) {
            set(level, c.x, i, floor);
        }
    }
    for (Room.Door door : room.connected.values()) {
        door.set(Room.Door.Type.TUNNEL);
    }
}
Also used : Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 15 with Point

use of com.watabou.utils.Point in project pixel-dungeon by watabou.

the class AltarPainter method paint.

public static void paint(Level level, Room room) {
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Dungeon.bossLevel(Dungeon.depth + 1) ? Terrain.HIGH_GRASS : Terrain.CHASM);
    Point c = room.center();
    Room.Door door = room.entrance();
    if (door.x == room.left || door.x == room.right) {
        Point p = drawInside(level, room, door, Math.abs(door.x - c.x) - 2, Terrain.EMPTY_SP);
        for (; p.y != c.y; p.y += p.y < c.y ? +1 : -1) {
            set(level, p, Terrain.EMPTY_SP);
        }
    } else {
        Point p = drawInside(level, room, door, Math.abs(door.y - c.y) - 2, Terrain.EMPTY_SP);
        for (; p.x != c.x; p.x += p.x < c.x ? +1 : -1) {
            set(level, p, Terrain.EMPTY_SP);
        }
    }
    fill(level, c.x - 1, c.y - 1, 3, 3, Terrain.EMBERS);
    set(level, c, Terrain.PEDESTAL);
    SacrificialFire fire = (SacrificialFire) level.blobs.get(SacrificialFire.class);
    if (fire == null) {
        fire = new SacrificialFire();
    }
    fire.seed(c.x + c.y * Level.WIDTH, 5 + Dungeon.depth * 5);
    level.blobs.put(SacrificialFire.class, fire);
    door.set(Room.Door.Type.EMPTY);
}
Also used : SacrificialFire(com.watabou.pixeldungeon.actors.blobs.SacrificialFire) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room)

Aggregations

Point (com.watabou.utils.Point)18 Room (com.watabou.pixeldungeon.levels.Room)11 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)6 Camera (com.watabou.noosa.Camera)2 Touch (com.watabou.input.Touchscreen.Touch)1 ColorBlock (com.watabou.noosa.ColorBlock)1 Group (com.watabou.noosa.Group)1 Image (com.watabou.noosa.Image)1 TouchArea (com.watabou.noosa.TouchArea)1 Alchemy (com.watabou.pixeldungeon.actors.blobs.Alchemy)1 SacrificialFire (com.watabou.pixeldungeon.actors.blobs.SacrificialFire)1 WellWater (com.watabou.pixeldungeon.actors.blobs.WellWater)1 Statue (com.watabou.pixeldungeon.actors.mobs.Statue)1 Item (com.watabou.pixeldungeon.items.Item)1 Archs (com.watabou.pixeldungeon.ui.Archs)1 RedButton (com.watabou.pixeldungeon.ui.RedButton)1 ArrayList (java.util.ArrayList)1