Search in sources :

Example 26 with Level

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

Example 27 with Level

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);
}
Also used : Position(com.nyrds.pixeldungeon.utils.Position) Level(com.watabou.pixeldungeon.levels.Level) InterstitialPoint(com.watabou.noosa.InterstitialPoint)

Example 28 with 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;
}
Also used : Level(com.watabou.pixeldungeon.levels.Level)

Example 29 with Level

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();
    }
}
Also used : LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) Char(com.watabou.pixeldungeon.actors.Char) Pushing(com.watabou.pixeldungeon.effects.Pushing) Level(com.watabou.pixeldungeon.levels.Level) Heap(com.watabou.pixeldungeon.items.Heap)

Example 30 with Level

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);
        }
    }
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Level(com.watabou.pixeldungeon.levels.Level) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener)

Aggregations

Level (com.watabou.pixeldungeon.levels.Level)37 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)7 Char (com.watabou.pixeldungeon.actors.Char)5 DeadEndLevel (com.watabou.pixeldungeon.levels.DeadEndLevel)5 LevelObject (com.nyrds.pixeldungeon.levels.objects.LevelObject)4 Pushing (com.watabou.pixeldungeon.effects.Pushing)4 IceCavesLevel (com.nyrds.pixeldungeon.levels.IceCavesLevel)3 NecroLevel (com.nyrds.pixeldungeon.levels.NecroLevel)3 Position (com.nyrds.pixeldungeon.utils.Position)3 Heap (com.watabou.pixeldungeon.items.Heap)3 CavesBossLevel (com.watabou.pixeldungeon.levels.CavesBossLevel)3 CavesLevel (com.watabou.pixeldungeon.levels.CavesLevel)3 CityBossLevel (com.watabou.pixeldungeon.levels.CityBossLevel)3 CityLevel (com.watabou.pixeldungeon.levels.CityLevel)3 HallsBossLevel (com.watabou.pixeldungeon.levels.HallsBossLevel)3 HallsLevel (com.watabou.pixeldungeon.levels.HallsLevel)3 LastLevel (com.watabou.pixeldungeon.levels.LastLevel)3 LastShopLevel (com.watabou.pixeldungeon.levels.LastShopLevel)3 PrisonBossLevel (com.watabou.pixeldungeon.levels.PrisonBossLevel)3 PrisonLevel (com.watabou.pixeldungeon.levels.PrisonLevel)3