Search in sources :

Example 16 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class Level method updateFieldOfView.

public boolean[] updateFieldOfView(Char c) {
    int cx = c.pos % WIDTH;
    int cy = c.pos / WIDTH;
    boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.isAlive();
    if (sighted) {
        ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
    } else {
        Arrays.fill(fieldOfView, false);
    }
    int sense = 1;
    if (c.isAlive()) {
        for (Buff b : c.buffs(MindVision.class)) {
            sense = Math.max(((MindVision) b).distance, sense);
        }
    }
    if ((sighted && sense > 1) || !sighted) {
        int ax = Math.max(0, cx - sense);
        int bx = Math.min(cx + sense, WIDTH - 1);
        int ay = Math.max(0, cy - sense);
        int by = Math.min(cy + sense, HEIGHT - 1);
        int len = bx - ax + 1;
        int pos = ax + ay * WIDTH;
        for (int y = ay; y <= by; y++, pos += WIDTH) {
            Arrays.fill(fieldOfView, pos, pos + len, true);
        }
        for (int i = 0; i < LENGTH; i++) {
            fieldOfView[i] &= discoverable[i];
        }
    }
    if (c.isAlive()) {
        if (c.buff(MindVision.class) != null) {
            for (Mob mob : mobs) {
                int p = mob.pos;
                fieldOfView[p] = true;
                fieldOfView[p + 1] = true;
                fieldOfView[p - 1] = true;
                fieldOfView[p + WIDTH + 1] = true;
                fieldOfView[p + WIDTH - 1] = true;
                fieldOfView[p - WIDTH + 1] = true;
                fieldOfView[p - WIDTH - 1] = true;
                fieldOfView[p + WIDTH] = true;
                fieldOfView[p - WIDTH] = true;
            }
        } else if (c == Dungeon.hero && ((Hero) c).heroClass == HeroClass.HUNTRESS) {
            for (Mob mob : mobs) {
                int p = mob.pos;
                if (distance(c.pos, p) == 2) {
                    fieldOfView[p] = true;
                    fieldOfView[p + 1] = true;
                    fieldOfView[p - 1] = true;
                    fieldOfView[p + WIDTH + 1] = true;
                    fieldOfView[p + WIDTH - 1] = true;
                    fieldOfView[p - WIDTH + 1] = true;
                    fieldOfView[p - WIDTH - 1] = true;
                    fieldOfView[p + WIDTH] = true;
                    fieldOfView[p - WIDTH] = true;
                }
            }
        }
        if (c.buff(Awareness.class) != null) {
            for (Heap heap : heaps.values()) {
                int p = heap.pos;
                fieldOfView[p] = true;
                fieldOfView[p + 1] = true;
                fieldOfView[p - 1] = true;
                fieldOfView[p + WIDTH + 1] = true;
                fieldOfView[p + WIDTH - 1] = true;
                fieldOfView[p - WIDTH + 1] = true;
                fieldOfView[p - WIDTH - 1] = true;
                fieldOfView[p + WIDTH] = true;
                fieldOfView[p - WIDTH] = true;
            }
        }
    }
    return fieldOfView;
}
Also used : Shadows(com.watabou.pixeldungeon.actors.buffs.Shadows) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Awareness(com.watabou.pixeldungeon.actors.buffs.Awareness) Blindness(com.watabou.pixeldungeon.actors.buffs.Blindness) Buff(com.watabou.pixeldungeon.actors.buffs.Buff) MindVision(com.watabou.pixeldungeon.actors.buffs.MindVision) Heap(com.watabou.pixeldungeon.items.Heap)

Example 17 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class LootIndicator method update.

@Override
public void update() {
    if (Dungeon.hero.ready) {
        Heap heap = Dungeon.level.heaps.get(Dungeon.hero.pos);
        if (heap != null && heap.type != Heap.Type.HIDDEN) {
            Item item = heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST : heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST : heap.type == Heap.Type.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : heap.peek();
            if (item != lastItem || item.quantity() != lastQuantity) {
                lastItem = item;
                lastQuantity = item.quantity();
                slot.item(item);
                flash();
            }
            visible = true;
        } else {
            lastItem = null;
            visible = false;
        }
    }
    slot.enable(visible && Dungeon.hero.ready);
    super.update();
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Heap(com.watabou.pixeldungeon.items.Heap)

Example 18 with Heap

use of com.watabou.pixeldungeon.items.Heap 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)

Example 19 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class NPC method throwItem.

protected void throwItem() {
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int n;
        do {
            n = pos + Level.NEIGHBOURS8[Random.Int(8)];
        } while (!Level.passable[n] && !Level.avoid[n]);
        Dungeon.level.drop(heap.pickUp(), n).sprite.drop(pos);
    }
}
Also used : Heap(com.watabou.pixeldungeon.items.Heap)

Example 20 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class Shopkeeper method flee.

protected void flee() {
    for (Heap heap : Dungeon.level.heaps.values()) {
        if (heap.type == Heap.Type.FOR_SALE) {
            CellEmitter.get(heap.pos).burst(ElmoParticle.FACTORY, 4);
            heap.destroy();
        }
    }
    destroy();
    sprite.killAndErase();
    CellEmitter.get(pos).burst(ElmoParticle.FACTORY, 6);
}
Also used : Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Heap (com.watabou.pixeldungeon.items.Heap)20 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)6 Char (com.watabou.pixeldungeon.actors.Char)4 Item (com.watabou.pixeldungeon.items.Item)3 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)3 Plant (com.watabou.pixeldungeon.plants.Plant)3 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)2 Buff (com.watabou.pixeldungeon.actors.buffs.Buff)2 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)2 PotionOfStrength (com.watabou.pixeldungeon.items.potions.PotionOfStrength)2 ScrollOfEnchantment (com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment)2 WndTradeItem (com.watabou.pixeldungeon.windows.WndTradeItem)2 Awareness (com.watabou.pixeldungeon.actors.buffs.Awareness)1 Blindness (com.watabou.pixeldungeon.actors.buffs.Blindness)1 Burning (com.watabou.pixeldungeon.actors.buffs.Burning)1 MindVision (com.watabou.pixeldungeon.actors.buffs.MindVision)1 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)1 Mimic (com.watabou.pixeldungeon.actors.mobs.Mimic)1 NPC (com.watabou.pixeldungeon.actors.mobs.npcs.NPC)1 RatKing (com.watabou.pixeldungeon.actors.mobs.npcs.RatKing)1