Search in sources :

Example 1 with Swap

use of com.watabou.pixeldungeon.effects.Swap in project pixel-dungeon by watabou.

the class WandOfReach method onZap.

@Override
protected void onZap(int cell) {
    int reach = Math.min(Ballistica.distance, power() + 4);
    boolean mapUpdated = false;
    for (int i = 1; i < reach; i++) {
        int c = Ballistica.trace[i];
        int before = Dungeon.level.map[c];
        Char ch = Actor.findChar(c);
        if (ch != null) {
            Actor.addDelayed(new Swap(curUser, ch), -1);
            break;
        }
        Heap heap = Dungeon.level.heaps.get(c);
        if (heap != null) {
            switch(heap.type) {
                case HEAP:
                    transport(heap);
                    break;
                case CHEST:
                case MIMIC:
                case TOMB:
                case SKELETON:
                    heap.open(curUser);
                    break;
                default:
            }
            break;
        }
        Dungeon.level.press(c, null);
        if (before == Terrain.OPEN_DOOR) {
            Level.set(c, Terrain.DOOR);
            GameScene.updateMap(c);
        } else if (Level.water[c]) {
            GameScene.ripple(c);
        }
        mapUpdated = mapUpdated || Dungeon.level.map[c] != before;
    }
    if (mapUpdated) {
        Dungeon.observe();
    }
}
Also used : Swap(com.watabou.pixeldungeon.effects.Swap) Char(com.watabou.pixeldungeon.actors.Char) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Char (com.watabou.pixeldungeon.actors.Char)1 Swap (com.watabou.pixeldungeon.effects.Swap)1 Heap (com.watabou.pixeldungeon.items.Heap)1