public static void reallyDie(Object cause) { int length = Level.LENGTH; int[] map = Dungeon.level.map; boolean[] visited = Dungeon.level.visited; boolean[] discoverable = Level.discoverable; for (int i = 0; i < length; i++) { int terr = map[i]; if (discoverable[i]) { visited[i] = true; if ((Terrain.flags[terr] & Terrain.SECRET) != 0) { Level.set(i, Terrain.discover(terr)); GameScene.updateMap(i); } } } Bones.leave(); Dungeon.observe(); Dungeon.hero.belongings.identify(); GameScene.gameOver(); if (cause instanceof Hero.Doom) { ((Hero.Doom) cause).onDeath(); } Dungeon.deleteGame(Dungeon.hero.heroClass, true); }
private void actAscend(HeroAction.Ascend action) { int stairs = action.dst; if (pos == stairs && pos == Dungeon.level.entrance) { if (Dungeon.depth == 1) { if (belongings.getItem(Amulet.class) == null) { GameScene.show(new WndMessage(TXT_LEAVE)); ready(); } else { Dungeon.deleteGame(Dungeon.hero.heroClass, true); Game.switchScene(SurfaceScene.class); } } else { curAction = null; Hunger hunger = buff(Hunger.class); if (hunger != null && !hunger.isStarving()) { hunger.satisfy(-Hunger.STARVING / 10); } InterlevelScene.mode = InterlevelScene.Mode.ASCEND; Game.switchScene(InterlevelScene.class); } } else if (getCloser(stairs)) { } else { ready(); } }
@Override public void die(Object cause) { curAction = null; DewVial.autoDrink(this); if (isAlive()) { new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f); return; } Actor.fixTime(); super.die(cause); Ankh ankh = (Ankh) belongings.getItem(Ankh.class); if (ankh == null) { reallyDie(cause); } else { Dungeon.deleteGame(Dungeon.hero.heroClass, false); GameScene.show(new WndResurrect(ankh, cause)); } }
@Override public void onDeath() { Badges.validateDeathFromGas(); Dungeon.fail(Utils.format(ResultDescriptions.GAS, Dungeon.depth)); GLog.n("You died from a toxic gas.."); }
@Override public void onMotionComplete() { Dungeon.observe(); search(false); super.onMotionComplete(); }
private void actMove(HeroAction.Move action) { if (getCloser(action.dst)) { } else { if (Dungeon.level.map[pos] == Terrain.SIGN) { GameScene.show(new WndMessage(Dungeon.tip())); } ready(); } }
private boolean getCloser(final int target) { if (rooted) { return false; } int step = -1; if (Level.adjacent(pos, target)) { if (Actor.findChar(target) == null) { if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) { Chasm.heroJump(this); interrupt(); return false; } if (Level.passable[target] || Level.avoid[target]) { step = target; } } } else { int len = Level.LENGTH; boolean[] p = Level.passable; boolean[] v = Dungeon.level.visited; boolean[] m = Dungeon.level.mapped; boolean[] passable = new boolean[len]; for (int i = 0; i < len; i++) { passable[i] = p[i] && (v[i] || m[i]); } step = Dungeon.findPath(this, pos, target, passable, Level.fieldOfView); } if (step != -1) { sprite.move(pos, step); move(step); spend(1 / speed()); return true; } else { return false; } }