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;
}
}
}
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);
}
}
}
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;
}
Aggregations