Search in sources :

Example 6 with Trap

use of com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap in project shattered-pixel-dungeon-gdx by 00-Evan.

the class PrisonBossLevel method resetTraps.

private void resetTraps() {
    traps.clear();
    for (int i = 0; i < length(); i++) {
        if (map[i] == Terrain.INACTIVE_TRAP) {
            Trap t = new GrippingTrap().reveal();
            t.active = false;
            setTrap(t, i);
            map[i] = Terrain.INACTIVE_TRAP;
        }
    }
}
Also used : GrippingTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrippingTrap) GrippingTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrippingTrap) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)

Example 7 with Trap

use of com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularPainter method paintTraps.

protected void paintTraps(Level l, ArrayList<Room> rooms) {
    ArrayList<Integer> validCells = new ArrayList<>();
    if (!rooms.isEmpty()) {
        for (Room r : rooms) {
            for (Point p : r.trapPlaceablePoints()) {
                int i = l.pointToCell(p);
                if (l.map[i] == Terrain.EMPTY) {
                    validCells.add(i);
                }
            }
        }
    } else {
        for (int i = 0; i < l.length(); i++) {
            if (l.map[i] == Terrain.EMPTY) {
                validCells.add(i);
            }
        }
    }
    // no more than one trap every 5 valid tiles.
    nTraps = Math.min(nTraps, validCells.size() / 5);
    for (int i = 0; i < nTraps; i++) {
        Integer trapPos = Random.element(validCells);
        // removes the integer object, not at the index
        validCells.remove(trapPos);
        try {
            Trap trap = trapClasses[Random.chances(trapChances)].newInstance().hide();
            l.setTrap(trap, trapPos);
            // some traps will not be hidden
            l.map[trapPos] = trap.visible ? Terrain.TRAP : Terrain.SECRET_TRAP;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap) Point(com.watabou.utils.Point) EmptyRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) Point(com.watabou.utils.Point)

Example 8 with Trap

use of com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CavesBossLevel method build.

@Override
protected boolean build() {
    setSize(WIDTH, HEIGHT);
    Rect space = new Rect();
    space.set(Random.IntRange(2, 2 + (int) (width * 0.2f)), Random.IntRange(2, 2 + (int) (height * 0.2f)), Random.IntRange((int) (width * 0.8f - 2), width - 2), Random.IntRange((int) (height * 0.8f - 2), height - 2));
    Painter.fillEllipse(this, space, Terrain.EMPTY);
    exit = space.left + space.width() / 2 + (space.top - 1) * width();
    map[exit] = Terrain.LOCKED_EXIT;
    Painter.fill(this, ROOM_LEFT - 1, ROOM_TOP - 1, ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL);
    Painter.fill(this, ROOM_LEFT, ROOM_TOP + 1, ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP, Terrain.EMPTY);
    Painter.fill(this, ROOM_LEFT, ROOM_TOP, ROOM_RIGHT - ROOM_LEFT + 1, 1, Terrain.EMPTY_DECO);
    arenaDoor = Random.Int(ROOM_LEFT, ROOM_RIGHT) + (ROOM_BOTTOM + 1) * width();
    map[arenaDoor] = Terrain.DOOR;
    entrance = Random.Int(ROOM_LEFT + 1, ROOM_RIGHT - 1) + Random.Int(ROOM_TOP + 1, ROOM_BOTTOM - 1) * width();
    map[entrance] = Terrain.ENTRANCE;
    boolean[] patch = Patch.generate(width, height, 0.30f, 6, true);
    for (int i = 0; i < length(); i++) {
        if (map[i] == Terrain.EMPTY && patch[i]) {
            map[i] = Terrain.WATER;
        }
    }
    for (int i = 0; i < length(); i++) {
        if (map[i] == Terrain.EMPTY && Random.Int(6) == 0) {
            map[i] = Terrain.INACTIVE_TRAP;
            Trap t = new ToxicTrap().reveal();
            t.active = false;
            setTrap(t, i);
        }
    }
    for (int i = width() + 1; i < length() - width(); i++) {
        if (map[i] == Terrain.EMPTY) {
            int n = 0;
            if (map[i + 1] == Terrain.WALL) {
                n++;
            }
            if (map[i - 1] == Terrain.WALL) {
                n++;
            }
            if (map[i + width()] == Terrain.WALL) {
                n++;
            }
            if (map[i - width()] == Terrain.WALL) {
                n++;
            }
            if (Random.Int(8) <= n) {
                map[i] = Terrain.EMPTY_DECO;
            }
        }
    }
    for (int i = 0; i < length() - width(); i++) {
        if (map[i] == Terrain.WALL && DungeonTileSheet.floorTile(map[i + width()]) && Random.Int(3) == 0) {
            map[i] = Terrain.WALL_DECO;
        }
    }
    return true;
}
Also used : Rect(com.watabou.utils.Rect) ToxicTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap) ToxicTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap)

Aggregations

Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)8 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)3 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)3 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)2 ArrayList (java.util.ArrayList)2 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)1 TimekeepersHourglass (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass)1 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)1 EmptyRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom)1 GrippingTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrippingTrap)1 ToxicTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap)1 CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)1 WndInfoCell (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoCell)1 WndInfoMob (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob)1 WndInfoPlant (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant)1 WndInfoTrap (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoTrap)1 WndOptions (com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions)1 Bundlable (com.watabou.utils.Bundlable)1 Point (com.watabou.utils.Point)1 Rect (com.watabou.utils.Rect)1