Search in sources :

Example 21 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon by watabou.

the class InterlevelScene method restore.

private void restore() throws Exception {
    Actor.fixTime();
    GameLog.wipe();
    Dungeon.loadGame(StartScene.curClass);
    if (Dungeon.depth == -1) {
        Dungeon.depth = Statistics.deepestFloor;
        Dungeon.switchLevel(Dungeon.loadLevel(StartScene.curClass), -1);
    } else {
        Level level = Dungeon.loadLevel(StartScene.curClass);
        Dungeon.switchLevel(level, Level.resizingNeeded ? level.adjustPos(Dungeon.hero.pos) : Dungeon.hero.pos);
    }
}
Also used : Level(com.watabou.pixeldungeon.levels.Level)

Example 22 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon by watabou.

the class InterlevelScene method ascend.

private void ascend() throws Exception {
    Actor.fixTime();
    Dungeon.saveLevel();
    Dungeon.depth--;
    Level level = Dungeon.loadLevel(Dungeon.hero.heroClass);
    Dungeon.switchLevel(level, level.exit);
}
Also used : Level(com.watabou.pixeldungeon.levels.Level)

Example 23 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon by watabou.

the class InterlevelScene method resurrect.

private void resurrect() throws Exception {
    Actor.fixTime();
    if (Dungeon.bossLevel()) {
        Dungeon.hero.resurrect(Dungeon.depth);
        Dungeon.depth--;
        Level level = Dungeon.newLevel();
        Dungeon.switchLevel(level, level.entrance);
    } else {
        Dungeon.hero.resurrect(-1);
        Dungeon.resetLevel();
    }
}
Also used : Level(com.watabou.pixeldungeon.levels.Level)

Example 24 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon by watabou.

the class Dungeon method loadLevel.

public static Level loadLevel(HeroClass cl) throws IOException {
    Dungeon.level = null;
    Actor.clear();
    InputStream input = Game.instance.openFileInput(Utils.format(depthFile(cl), depth));
    Bundle bundle = Bundle.read(input);
    input.close();
    return (Level) bundle.get("level");
}
Also used : InputStream(java.io.InputStream) Bundle(com.watabou.utils.Bundle) PrisonLevel(com.watabou.pixeldungeon.levels.PrisonLevel) HallsBossLevel(com.watabou.pixeldungeon.levels.HallsBossLevel) CavesBossLevel(com.watabou.pixeldungeon.levels.CavesBossLevel) DeadEndLevel(com.watabou.pixeldungeon.levels.DeadEndLevel) LastLevel(com.watabou.pixeldungeon.levels.LastLevel) CityLevel(com.watabou.pixeldungeon.levels.CityLevel) LastShopLevel(com.watabou.pixeldungeon.levels.LastShopLevel) CavesLevel(com.watabou.pixeldungeon.levels.CavesLevel) SewerBossLevel(com.watabou.pixeldungeon.levels.SewerBossLevel) PrisonBossLevel(com.watabou.pixeldungeon.levels.PrisonBossLevel) Level(com.watabou.pixeldungeon.levels.Level) SewerLevel(com.watabou.pixeldungeon.levels.SewerLevel) CityBossLevel(com.watabou.pixeldungeon.levels.CityBossLevel) HallsLevel(com.watabou.pixeldungeon.levels.HallsLevel)

Example 25 with Level

use of com.watabou.pixeldungeon.levels.Level in project pixel-dungeon-remix by NYRDS.

the class GameScene method create.

@Override
public void create() {
    playLevelMusic();
    Level level = Dungeon.level;
    PixelDungeon.lastClass(Dungeon.hero.heroClass.ordinal());
    super.create();
    Camera.main.zoom((float) (defaultZoom + PixelDungeon.zoom()));
    scene = this;
    Group terrain = new Group();
    add(terrain);
    water = new SkinnedBlock(level.getWidth() * DungeonTilemap.SIZE, level.getHeight() * DungeonTilemap.SIZE, level.getWaterTex());
    waterSx = DungeonGenerator.getLevelProperty(level.levelId, "waterSx", waterSx);
    waterSy = DungeonGenerator.getLevelProperty(level.levelId, "waterSy", waterSy);
    terrain.add(water);
    ripples = new Group();
    terrain.add(ripples);
    String logicTilesAtlas = level.getProperty("tiles_logic", null);
    if (logicTilesAtlas != null) {
        logicTiles = new ClassicDungeonTilemap(level, logicTilesAtlas);
        terrain.add(logicTiles);
    }
    if (!level.customTiles()) {
        baseTiles = DungeonTilemap.factory(level, level.getTilesetForLayer(Level.LayerId.Base));
    } else {
        CustomLayerTilemap tiles = new CustomLayerTilemap(level, Level.LayerId.Base);
        tiles.addLayer(Level.LayerId.Deco);
        tiles.addLayer(Level.LayerId.Deco2);
        baseTiles = tiles;
        tiles = new CustomLayerTilemap(level, Level.LayerId.Roof_Base);
        tiles.addLayer(Level.LayerId.Roof_Deco);
        tiles.setTransparent(true);
        roofTiles = tiles;
    }
    terrain.add(baseTiles);
    objects = new Group();
    add(objects);
    for (int i = 0; i < level.objects.size(); i++) {
        SparseArray<LevelObject> objectLayer = level.objects.valueAt(i);
        for (int j = 0; j < objectLayer.size(); j++) {
            addLevelObjectSprite(objectLayer.valueAt(j));
        }
    }
    level.addVisuals(this);
    plants = new Group();
    add(plants);
    for (int i = 0; i < level.plants.size(); i++) {
        addPlantSprite(level.plants.valueAt(i));
    }
    heaps = new Group();
    add(heaps);
    for (Heap heap : level.allHeaps()) {
        addHeapSprite(heap);
    }
    emitters = new Group();
    effects = new Group();
    emoicons = new Group();
    mobs = new Group();
    add(mobs);
    // hack to save bugged saves...
    boolean buggedSave = false;
    HashSet<Mob> filteredMobs = new HashSet<>();
    for (Mob mob : level.mobs) {
        if (level.cellValid(mob.getPos())) {
            filteredMobs.add(mob);
        } else {
            buggedSave = true;
        }
    }
    if (buggedSave) {
        EventCollector.logEvent(EventCollector.BUG, "bugged save", "mob.pos==-1");
    }
    level.mobs = filteredMobs;
    for (Mob mob : level.mobs) {
        if (Statistics.amuletObtained) {
            mob.beckon(Dungeon.hero.getPos());
        }
    }
    Dungeon.hero.updateSprite();
    add(emitters);
    add(effects);
    gases = new Group();
    add(gases);
    for (Blob blob : level.blobs.values()) {
        blob.emitter = null;
        addBlobSprite(blob);
    }
    fog = new FogOfWar(level.getWidth(), level.getHeight());
    if (level.noFogOfWar()) {
        level.reveal();
    }
    if (roofTiles != null) {
        add(roofTiles);
    }
    fog.updateVisibility(Dungeon.visible, level.visited, level.mapped);
    add(fog);
    brightness(PixelDungeon.brightness());
    spells = new Group();
    add(spells);
    statuses = new Group();
    add(statuses);
    add(emoicons);
    add(new HealthIndicator());
    add(cellSelector = new CellSelector(baseTiles));
    Dungeon.hero.updateLook();
    sb = new StatusPane(Dungeon.hero, level);
    sb.camera = uiCamera;
    sb.setSize(uiCamera.width, 0);
    add(sb);
    toolbar = new Toolbar();
    toolbar.camera = uiCamera;
    toolbar.setRect(0, uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height());
    add(toolbar);
    attack = new AttackIndicator();
    attack.camera = uiCamera;
    attack.setPos(uiCamera.width - attack.width(), toolbar.top() - attack.height());
    add(attack);
    resume = new ResumeIndicator();
    resume.camera = uiCamera;
    resume.setPos(uiCamera.width - resume.width(), attack.top() - resume.height());
    add(resume);
    log = new GameLog();
    log.camera = uiCamera;
    log.setRect(0, toolbar.top(), attack.left(), 0);
    add(log);
    if (Dungeon.depth < Statistics.deepestFloor) {
        GLog.i(TXT_WELCOME_BACK, Dungeon.depth);
    } else {
        GLog.i(TXT_WELCOME, Dungeon.depth);
        Sample.INSTANCE.play(Assets.SND_DESCEND);
    }
    switch(level.getFeeling()) {
        case CHASM:
            GLog.w(TXT_CHASM);
            break;
        case WATER:
            GLog.w(TXT_WATER);
            break;
        case GRASS:
            GLog.w(TXT_GRASS);
            break;
        default:
    }
    if (level instanceof RegularLevel && ((RegularLevel) level).secretDoors > Random.IntRange(3, 4)) {
        GLog.w(TXT_SECRETS);
    }
    if (Dungeon.nightMode && !Dungeon.bossLevel()) {
        GLog.w(TXT_NIGHT_MODE);
    }
    busy = new BusyIndicator();
    busy.camera = uiCamera;
    busy.x = 1;
    busy.y = sb.bottom() + 18;
    add(busy);
    sceneCreated = true;
    switch(InterlevelScene.mode) {
        case RESURRECT:
            WandOfBlink.appear(Dungeon.hero, level.entrance);
            new Flare(8, 32).color(0xFFFF66, true).show(Dungeon.hero.getHeroSprite(), 2f);
            break;
        case RETURN:
            WandOfBlink.appear(Dungeon.hero, Dungeon.hero.getPos());
            break;
        case FALL:
            Chasm.heroLand();
            break;
        case DESCEND:
            DungeonGenerator.showStory(level);
            if (Dungeon.hero.isAlive() && !level.isSafe() && Dungeon.depth != 22 && Dungeon.depth != 1) {
                Badges.validateNoKilling();
            }
            break;
        default:
    }
    Camera.main.target = Dungeon.hero.getHeroSprite();
    level.activateScripts();
    fadeIn();
    Dungeon.observe();
}
Also used : Group(com.watabou.noosa.Group) StatusPane(com.watabou.pixeldungeon.ui.StatusPane) LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) AttackIndicator(com.watabou.pixeldungeon.ui.AttackIndicator) BusyIndicator(com.watabou.pixeldungeon.ui.BusyIndicator) SkinnedBlock(com.watabou.noosa.SkinnedBlock) GameLog(com.watabou.pixeldungeon.ui.GameLog) HashSet(java.util.HashSet) Toolbar(com.watabou.pixeldungeon.ui.Toolbar) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) FogOfWar(com.watabou.pixeldungeon.FogOfWar) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) Flare(com.watabou.pixeldungeon.effects.Flare) ClassicDungeonTilemap(com.watabou.pixeldungeon.ClassicDungeonTilemap) Heap(com.watabou.pixeldungeon.items.Heap) ResumeIndicator(com.watabou.pixeldungeon.ui.ResumeIndicator) HealthIndicator(com.watabou.pixeldungeon.ui.HealthIndicator) Level(com.watabou.pixeldungeon.levels.Level) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel) CustomLayerTilemap(com.watabou.pixeldungeon.CustomLayerTilemap) RegularLevel(com.watabou.pixeldungeon.levels.RegularLevel)

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