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