use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class InterlevelScene method resurrect.
private void resurrect() {
Actor.fixTime();
if (Dungeon.bossLevel()) {
Dungeon.hero.resurrect(Dungeon.depth);
Level level = Dungeon.newLevel(Dungeon.currentPosition());
Dungeon.switchLevel(level, level.entrance, Dungeon.hero.levelId);
} else {
Dungeon.hero.resurrect(-1);
Dungeon.resetLevel();
}
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class InterlevelScene method ascend.
private void ascend() throws IOException {
Actor.fixTime();
Position next = DungeonGenerator.ascend(Dungeon.currentPosition());
Dungeon.level.removePets();
Dungeon.save();
Dungeon.depth = DungeonGenerator.getLevelDepth(next.levelId);
Level level = Dungeon.loadLevel(next);
int exitIndex = -(next.cellId + 1);
Dungeon.switchLevel(level, level.getExit(exitIndex), next.levelId);
Dungeon.hero.spawnPets(level);
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class Ballistica method cast.
public static int cast(int from, int to, boolean magic, boolean hitChars, boolean hitObjects) {
Level level = Dungeon.level;
int w = level.getWidth();
int lSize = Math.max(w, level.getHeight());
if (trace.length < lSize) {
trace = new int[lSize];
}
int x0 = from % w;
int x1 = to % w;
int y0 = from / w;
int y1 = to / w;
int dx = x1 - x0;
int dy = y1 - y0;
int stepX = dx > 0 ? +1 : -1;
int stepY = dy > 0 ? +1 : -1;
dx = Math.abs(dx);
dy = Math.abs(dy);
int stepA;
int stepB;
int dA;
int dB;
if (dx > dy) {
stepA = stepX;
stepB = stepY * w;
dA = dx;
dB = dy;
} else {
stepA = stepY * w;
stepB = stepX;
dA = dy;
dB = dx;
}
distance = 1;
trace[0] = from;
int cell = from;
int err = dA / 2;
while (cell != to || magic) {
cell += stepA;
err += dB;
if (err >= dA) {
err = err - dA;
cell = cell + stepB;
}
trace[distance++] = cell;
if (!level.passable[cell] && !level.avoid[cell]) {
return trace[--distance - 1];
}
if (level.losBlocking[cell] || (hitChars && Actor.findChar(cell) != null) || (hitObjects && level.getLevelObject(cell) != null)) {
return cell;
}
}
trace[distance++] = cell;
return to;
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class WandOfTelekinesis method onZap.
@Override
protected void onZap(int cell) {
boolean mapUpdated = false;
int maxDistance = effectiveLevel() + 4;
Ballistica.distance = Math.min(Ballistica.distance, maxDistance);
Char ch;
Heap heap = null;
Level level = Dungeon.level;
for (int i = 1; i < Ballistica.distance; i++) {
int c = Ballistica.trace[i];
int before = level.map[c];
if ((ch = Actor.findChar(c)) != null) {
if (i == Ballistica.distance - 1) {
ch.damage(maxDistance - 1 - i, this);
} else {
int next = Ballistica.trace[i + 1];
if (ch.isMovable() && (level.passable[next] || level.avoid[next]) && Actor.findChar(next) == null) {
Actor.addDelayed(new Pushing(ch, ch.getPos(), next), -1);
ch.setPos(next);
Actor.freeCell(next);
level.press(ch.getPos(), ch);
} else {
ch.damage(maxDistance - 1 - i, this);
}
}
}
if (heap == null && (heap = level.getHeap(c)) != null) {
switch(heap.type) {
case HEAP:
transport(heap);
break;
case CHEST:
case MIMIC:
heap.open(getCurUser());
break;
default:
}
}
level.press(c, new Effect());
if (before == Terrain.OPEN_DOOR && Actor.findChar(c) == null) {
level.set(c, Terrain.DOOR);
GameScene.updateMap(c);
} else if (level.water[c]) {
GameScene.ripple(c);
}
if (!mapUpdated && level.map[c] != before) {
mapUpdated = true;
}
LevelObject levelObject = null;
if ((levelObject = level.getTopLevelObject(c)) != null) {
if (levelObject.pushable(getCurUser())) {
levelObject.push(getCurUser());
}
}
}
if (mapUpdated) {
Dungeon.observe();
}
}
use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.
the class ShadowLord method twistLevel.
private void twistLevel() {
if (!isAlive()) {
return;
}
Level level = Dungeon.level;
if (!levelCreated) {
Tools.makeEmptyLevel(level);
Tools.buildShadowLordMaze(level, 6);
levelCreated = true;
}
int cell = level.getRandomTerrainCell(Terrain.PEDESTAL);
if (level.cellValid(cell)) {
if (Actor.findChar(cell) == null) {
Mob mob = Crystal.makeShadowLordCrystal();
mob.setPos(cell);
level.spawnMob(mob);
mob.getSprite().alpha(0);
mob.getSprite().getParent().add(new AlphaTweener(mob.getSprite(), 1, 0.4f));
mob.getSprite().emitter().start(Speck.factory(Speck.LIGHT), 0.2f, 3);
Sample.INSTANCE.play(Assets.SND_TELEPORT);
int x, y;
x = level.cellX(cell);
y = level.cellY(cell);
level.fillAreaWith(Darkness.class, x - 2, y - 2, 5, 5, 1);
} else {
damage(ht() / 9, this);
}
}
}
Aggregations