Search in sources :

Example 1 with Position

use of com.nyrds.pixeldungeon.utils.Position in project pixel-dungeon-remix by NYRDS.

the class Hero method actAscend.

private boolean actAscend(HeroAction.Ascend action) {
    refreshPets();
    int stairs = action.dst;
    if (getPos() == stairs && getPos() == Dungeon.level.entrance) {
        Position nextLevel = DungeonGenerator.ascend(Dungeon.currentPosition());
        if (nextLevel.levelId.equals("0")) {
            if (belongings.getItem(Amulet.class) == null) {
                GameScene.show(new WndMessage(TXT_LEAVE));
                ready();
            } else {
                Dungeon.win(ResultDescriptions.WIN, Rankings.gameOver.WIN_HAPPY);
                Dungeon.gameOver();
                Game.switchScene(SurfaceScene.class);
            }
        } else {
            clearActions();
            Hunger hunger = buff(Hunger.class);
            if (hunger != null && !hunger.isStarving() && !Dungeon.level.isSafe()) {
                hunger.satisfy(-Hunger.STARVING / 10);
            }
            InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
            Game.switchScene(InterlevelScene.class);
        }
        return false;
    } else if (getCloser(stairs)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Hunger(com.watabou.pixeldungeon.actors.buffs.Hunger) Amulet(com.watabou.pixeldungeon.items.Amulet) Position(com.nyrds.pixeldungeon.utils.Position) WndMessage(com.watabou.pixeldungeon.windows.WndMessage)

Example 2 with Position

use of com.nyrds.pixeldungeon.utils.Position in project pixel-dungeon-remix by NYRDS.

the class Dungeon method saveAllImpl.

private static void saveAllImpl() {
    float MBytesAvailable = Game.getAvailableInternalMemorySize() / 1024f / 1024f;
    if (MBytesAvailable < 2) {
        EventCollector.logEvent("saveGame", "lowMemory");
        Game.toast("Low memory condition");
    }
    if (hero.isAlive()) {
        Actor.fixTime();
        try {
            Position current = currentPosition();
            String saveToLevel = SaveUtils.depthFileForSave(hero.heroClass, DungeonGenerator.getLevelDepth(current.levelId), DungeonGenerator.getLevelKind(current.levelId), current.levelId);
            String saveToGame = SaveUtils.gameFile(hero.heroClass);
            saveGame("tmp.game");
            saveLevel("tmp.level");
            FileSystem.getInternalStorageFile(saveToGame).delete();
            FileSystem.getInternalStorageFile(saveToLevel).delete();
            FileSystem.getInternalStorageFile("tmp.game").renameTo(FileSystem.getInternalStorageFile(saveToGame));
            FileSystem.getInternalStorageFile("tmp.level").renameTo(FileSystem.getInternalStorageFile(saveToLevel));
        } catch (IOException e) {
            throw new TrackedRuntimeException("cannot write save", e);
        }
        GamesInProgress.set(hero.heroClass, depth, hero.lvl());
    } else if (WndResurrect.instance != null) {
        WndResurrect.instance.hide();
        Hero.reallyDie(WndResurrect.causeOfDeath);
    }
    Badges.saveGlobal();
    Library.saveLibrary();
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) Position(com.nyrds.pixeldungeon.utils.Position) IOException(java.io.IOException)

Example 3 with Position

use of com.nyrds.pixeldungeon.utils.Position in project pixel-dungeon-remix by NYRDS.

the class PortalGateSender method setupFromJson.

@Override
void setupFromJson(Level level, JSONObject obj) throws JSONException {
    super.setupFromJson(level, obj);
    if (obj.has("target")) {
        JSONObject portalDesc = obj.getJSONObject("target");
        String levelId = portalDesc.optString("levelId", "1");
        target = new Position(levelId, portalDesc.optInt("x", 1), portalDesc.optInt("y", 1));
    }
}
Also used : JSONObject(org.json.JSONObject) Position(com.nyrds.pixeldungeon.utils.Position)

Example 4 with Position

use of com.nyrds.pixeldungeon.utils.Position in project pixel-dungeon-remix by NYRDS.

the class InterlevelScene method descend.

private void descend() throws IOException {
    Actor.fixTime();
    if (Dungeon.hero == null) {
        Dungeon.init();
        if (noStory) {
            Dungeon.chapters.add(WndStory.ID_SEWERS);
            noStory = false;
        }
    } else {
        Dungeon.level.removePets();
        Dungeon.save();
    }
    Position next = DungeonGenerator.descend(Dungeon.currentPosition());
    Dungeon.depth = DungeonGenerator.getLevelDepth(next.levelId);
    Level level = Dungeon.loadLevel(next);
    Dungeon.switchLevel(level, level.entrance, next.levelId);
    Dungeon.hero.spawnPets(level);
}
Also used : Position(com.nyrds.pixeldungeon.utils.Position) Level(com.watabou.pixeldungeon.levels.Level)

Example 5 with Position

use of com.nyrds.pixeldungeon.utils.Position in project pixel-dungeon-remix by NYRDS.

the class InterlevelScene method fall.

private void fall() throws IOException {
    Actor.fixTime();
    Dungeon.level.removePets();
    Dungeon.save();
    Position next = DungeonGenerator.descend(Dungeon.currentPosition());
    Dungeon.depth = DungeonGenerator.getLevelDepth(next.levelId);
    Level level = Dungeon.loadLevel(next);
    Dungeon.switchLevel(level, fallIntoPit ? level.pitCell() : level.randomRespawnCell(), next.levelId);
}
Also used : Position(com.nyrds.pixeldungeon.utils.Position) Level(com.watabou.pixeldungeon.levels.Level)

Aggregations

Position (com.nyrds.pixeldungeon.utils.Position)6 Level (com.watabou.pixeldungeon.levels.Level)3 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1 InterstitialPoint (com.watabou.noosa.InterstitialPoint)1 Hunger (com.watabou.pixeldungeon.actors.buffs.Hunger)1 Amulet (com.watabou.pixeldungeon.items.Amulet)1 WndMessage (com.watabou.pixeldungeon.windows.WndMessage)1 IOException (java.io.IOException)1 JSONObject (org.json.JSONObject)1