Search in sources :

Example 11 with Heap

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

the class Hero method actOpenChest.

private boolean actOpenChest(HeroAction.OpenChest action) {
    int dst = action.dst;
    if (Level.adjacent(pos, dst) || pos == dst) {
        Heap heap = Dungeon.level.heaps.get(dst);
        if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) {
            theKey = null;
            if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST) {
                theKey = belongings.getKey(GoldenKey.class, Dungeon.depth);
                if (theKey == null) {
                    GLog.w(TXT_LOCKED_CHEST);
                    ready();
                    return false;
                }
            }
            switch(heap.type) {
                case TOMB:
                    Sample.INSTANCE.play(Assets.SND_TOMB);
                    Camera.main.shake(1, 0.5f);
                    break;
                case SKELETON:
                    break;
                default:
                    Sample.INSTANCE.play(Assets.SND_UNLOCK);
            }
            spend(Key.TIME_TO_UNLOCK);
            sprite.operate(dst);
        } else {
            ready();
        }
        return false;
    } else if (getCloser(dst)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : GoldenKey(com.watabou.pixeldungeon.items.keys.GoldenKey) Heap(com.watabou.pixeldungeon.items.Heap)

Example 12 with Heap

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

the class Hero method actPickUp.

private boolean actPickUp(HeroAction.PickUp action) {
    int dst = action.dst;
    if (pos == dst) {
        Heap heap = Dungeon.level.heaps.get(pos);
        if (heap != null) {
            Item item = heap.pickUp();
            if (item.doPickUp(this)) {
                if (item instanceof Dewdrop) {
                // Do nothing
                } else {
                    boolean important = ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll) item).isKnown()) || ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion) item).isKnown());
                    if (important) {
                        GLog.p(TXT_YOU_NOW_HAVE, item.name());
                    } else {
                        GLog.i(TXT_YOU_NOW_HAVE, item.name());
                    }
                }
                if (!heap.isEmpty()) {
                    GLog.i(TXT_SOMETHING_ELSE);
                }
                curAction = null;
            } else {
                Dungeon.level.drop(item, pos).sprite.drop();
                ready();
            }
        } else {
            ready();
        }
        return false;
    } else if (getCloser(dst)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) WndTradeItem(com.watabou.pixeldungeon.windows.WndTradeItem) PotionOfMight(com.watabou.pixeldungeon.items.potions.PotionOfMight) ScrollOfEnchantment(com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment) PotionOfStrength(com.watabou.pixeldungeon.items.potions.PotionOfStrength) Dewdrop(com.watabou.pixeldungeon.items.Dewdrop) Heap(com.watabou.pixeldungeon.items.Heap) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 13 with Heap

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

the class Hero method actBuy.

private boolean actBuy(HeroAction.Buy action) {
    int dst = action.dst;
    if (pos == dst || Level.adjacent(pos, dst)) {
        ready();
        Heap heap = Dungeon.level.heaps.get(dst);
        if (heap != null && heap.type == Type.FOR_SALE && heap.size() == 1) {
            GameScene.show(new WndTradeItem(heap, true));
        }
        return false;
    } else if (getCloser(dst)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : WndTradeItem(com.watabou.pixeldungeon.windows.WndTradeItem) Heap(com.watabou.pixeldungeon.items.Heap)

Example 14 with Heap

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

the class Fire method burn.

private void burn(int pos) {
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        Buff.affect(ch, Burning.class).reignite(ch);
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        heap.burn();
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) Heap(com.watabou.pixeldungeon.items.Heap) Burning(com.watabou.pixeldungeon.actors.buffs.Burning)

Example 15 with Heap

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

the class Level method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    mobs = new HashSet<Mob>();
    heaps = new SparseArray<Heap>();
    blobs = new HashMap<Class<? extends Blob>, Blob>();
    plants = new SparseArray<Plant>();
    map = bundle.getIntArray(MAP);
    visited = bundle.getBooleanArray(VISITED);
    mapped = bundle.getBooleanArray(MAPPED);
    entrance = bundle.getInt(ENTRANCE);
    exit = bundle.getInt(EXIT);
    weakFloorCreated = false;
    adjustMapSize();
    Collection<Bundlable> collection = bundle.getCollection(HEAPS);
    for (Bundlable h : collection) {
        Heap heap = (Heap) h;
        if (resizingNeeded) {
            heap.pos = adjustPos(heap.pos);
        }
        heaps.put(heap.pos, heap);
    }
    collection = bundle.getCollection(PLANTS);
    for (Bundlable p : collection) {
        Plant plant = (Plant) p;
        if (resizingNeeded) {
            plant.pos = adjustPos(plant.pos);
        }
        plants.put(plant.pos, plant);
    }
    collection = bundle.getCollection(MOBS);
    for (Bundlable m : collection) {
        Mob mob = (Mob) m;
        if (mob != null) {
            if (resizingNeeded) {
                mob.pos = adjustPos(mob.pos);
            }
            mobs.add(mob);
        }
    }
    collection = bundle.getCollection(BLOBS);
    for (Bundlable b : collection) {
        Blob blob = (Blob) b;
        blobs.put(blob.getClass(), blob);
    }
    buildFlagMaps();
    cleanWalls();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) Plant(com.watabou.pixeldungeon.plants.Plant) Bundlable(com.watabou.utils.Bundlable) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) 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