public boolean handle(int cell) { if (cell == -1) { return false; } Char ch; Heap heap; if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) { curAction = new HeroAction.Cook(cell); } else if (Level.fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) { if (ch instanceof NPC) { curAction = new HeroAction.Interact((NPC) ch); } else { curAction = new HeroAction.Attack(ch); } } else if (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get(cell)) != null && heap.type != Heap.Type.HIDDEN) { switch (heap.type) { case HEAP: curAction = new HeroAction.PickUp(cell); break; case FOR_SALE: curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell); break; default: curAction = new HeroAction.OpenChest(cell); } } else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) { curAction = new HeroAction.Unlock(cell); } else if (cell == Dungeon.level.exit) { curAction = new HeroAction.Descend(cell); } else if (cell == Dungeon.level.entrance) { curAction = new HeroAction.Ascend(cell); } else { curAction = new HeroAction.Move(cell); lastAction = null; } return act(); }
@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)); } }
private boolean getCloser(final int target) { if (rooted) { Camera.main.shake(1, 1f); 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) { int oldPos = pos; move(step); sprite.move(oldPos, pos); spend(1 / speed()); return true; } else { return false; } }
@Override protected void onZap(int cell) { Char ch = Actor.findChar(cell); if (ch != null) { if (ch == Dungeon.hero) { Buff.affect(ch, Vertigo.class, Vertigo.duration(ch)); } else { Buff.affect(ch, Amok.class, 3f + power()); } } else { GLog.i("nothing happened"); } }