use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method handle.
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.Alchemy(cell);
} else if (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 ((heap = Dungeon.level.heaps.get(cell)) != null && // moving to an item doesn't auto-pickup when enemies are near...
(visibleEnemies.size() == 0 || cell == pos || // ...but only for standard heaps, chests and similar open as normal.
(heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
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 && Dungeon.depth < 26) {
curAction = new HeroAction.Descend(cell);
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend(cell);
} else {
curAction = new HeroAction.Move(cell);
lastAction = null;
}
if (ready)
return act();
else
return false;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method actInteract.
private boolean actInteract(HeroAction.Interact action) {
NPC npc = action.npc;
if (Dungeon.level.adjacent(pos, npc.pos)) {
ready();
sprite.turnTo(pos, npc.pos);
return npc.interact();
} else {
if (fieldOfView[npc.pos] && getCloser(npc.pos)) {
return true;
} else {
ready();
return false;
}
}
}