Search in sources :

Example 1 with NPC

use of com.watabou.pixeldungeon.actors.mobs.npcs.NPC in project pixel-dungeon by watabou.

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.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();
}
Also used : NPC(com.watabou.pixeldungeon.actors.mobs.npcs.NPC) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Heap(com.watabou.pixeldungeon.items.Heap) Char(com.watabou.pixeldungeon.actors.Char)

Example 2 with NPC

use of com.watabou.pixeldungeon.actors.mobs.npcs.NPC in project pixel-dungeon by watabou.

the class Hero method actInteract.

private boolean actInteract(HeroAction.Interact action) {
    NPC npc = action.npc;
    if (Level.adjacent(pos, npc.pos)) {
        ready();
        sprite.turnTo(pos, npc.pos);
        npc.interact();
        return false;
    } else {
        if (Level.fieldOfView[npc.pos] && getCloser(npc.pos)) {
            return true;
        } else {
            ready();
            return false;
        }
    }
}
Also used : NPC(com.watabou.pixeldungeon.actors.mobs.npcs.NPC)

Aggregations

NPC (com.watabou.pixeldungeon.actors.mobs.npcs.NPC)2 Char (com.watabou.pixeldungeon.actors.Char)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Heap (com.watabou.pixeldungeon.items.Heap)1