Search in sources :

Example 56 with Item

use of com.watabou.pixeldungeon.items.Item 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 57 with Item

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

the class WndBag method placeItems.

protected void placeItems(Bag container) {
    // Equipped items
    Belongings stuff = Dungeon.hero.belongings;
    placeItem(stuff.weapon != null ? stuff.weapon : new Placeholder(ItemSpriteSheet.WEAPON));
    placeItem(stuff.armor != null ? stuff.armor : new Placeholder(ItemSpriteSheet.ARMOR));
    placeItem(stuff.ring1 != null ? stuff.ring1 : new Placeholder(ItemSpriteSheet.RING));
    placeItem(stuff.ring2 != null ? stuff.ring2 : new Placeholder(ItemSpriteSheet.RING));
    boolean backpack = (container == Dungeon.hero.belongings.backpack);
    if (!backpack) {
        count = nCols;
        col = 0;
        row = 1;
    }
    // Items in the bag
    for (Item item : container.items) {
        placeItem(item);
    }
    // Free space
    while (count - (backpack ? 4 : nCols) < container.size) {
        placeItem(null);
    }
    // Gold in the backpack
    if (container == Dungeon.hero.belongings.backpack) {
        row = nRows - 1;
        col = nCols - 1;
        placeItem(new Gold(Dungeon.gold));
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Gold(com.watabou.pixeldungeon.items.Gold) Belongings(com.watabou.pixeldungeon.actors.hero.Belongings)

Example 58 with Item

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

the class WndTradeItem method buy.

private void buy(Heap heap) {
    Hero hero = Dungeon.hero;
    Item item = heap.pickUp();
    int price = price(item);
    Dungeon.gold -= price;
    GLog.i(TXT_BOUGHT, item.name(), price);
    if (!item.doPickUp(hero)) {
        Dungeon.level.drop(item, heap.pos).sprite.drop();
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 59 with Item

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

the class WndWandmaker method onSelect.

@Override
protected void onSelect(int index) {
    questItem.detach(Dungeon.hero.belongings.backpack);
    Item reward = index == 0 ? Wandmaker.Quest.wand1 : Wandmaker.Quest.wand2;
    reward.identify();
    if (reward.doPickUp(Dungeon.hero)) {
        GLog.i(Hero.TXT_YOU_NOW_HAVE, reward.name());
    } else {
        Dungeon.level.drop(reward, wandmaker.pos).sprite.drop();
    }
    wandmaker.yell(Utils.format(TXT_FARAWELL, Dungeon.hero.className()));
    wandmaker.destroy();
    wandmaker.sprite.die();
    Wandmaker.Quest.complete();
}
Also used : Item(com.watabou.pixeldungeon.items.Item)

Example 60 with Item

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

the class WellWater method affect.

protected boolean affect() {
    Heap heap;
    if (pos == Dungeon.hero.pos && affectHero(Dungeon.hero)) {
        volume = off[pos] = cur[pos] = 0;
        return true;
    } else if ((heap = Dungeon.level.heaps.get(pos)) != null) {
        Item oldItem = heap.peek();
        Item newItem = affectItem(oldItem);
        if (newItem != null) {
            if (newItem == oldItem) {
            } else if (oldItem.quantity() > 1) {
                oldItem.quantity(oldItem.quantity() - 1);
                heap.drop(newItem);
            } else {
                heap.replace(oldItem, newItem);
            }
            heap.sprite.link();
            volume = off[pos] = cur[pos] = 0;
            return true;
        } else {
            int newPlace;
            do {
                newPlace = pos + Level.NEIGHBOURS8[Random.Int(8)];
            } while (!Level.passable[newPlace] && !Level.avoid[newPlace]);
            Dungeon.level.drop(heap.pickUp(), newPlace).sprite.drop(pos);
            return false;
        }
    } else {
        return false;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Item (com.watabou.pixeldungeon.items.Item)93 Hero (com.watabou.pixeldungeon.actors.hero.Hero)8 WndTradeItem (com.watabou.pixeldungeon.windows.WndTradeItem)8 Heap (com.watabou.pixeldungeon.items.Heap)6 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)6 Point (com.watabou.utils.Point)6 ArrayList (java.util.ArrayList)6 IChaosItem (com.nyrds.pixeldungeon.items.chaos.IChaosItem)5 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)5 Gold (com.watabou.pixeldungeon.items.Gold)5 WndQuest (com.watabou.pixeldungeon.windows.WndQuest)5 IActingItem (com.nyrds.pixeldungeon.items.artifacts.IActingItem)4 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)4 Wand (com.watabou.pixeldungeon.items.wands.Wand)4 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)3 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)3 TomeOfKnowledge (com.nyrds.pixeldungeon.items.books.TomeOfKnowledge)2 BlackSkull (com.nyrds.pixeldungeon.items.necropolis.BlackSkull)2 Char (com.watabou.pixeldungeon.actors.Char)2 Belongings (com.watabou.pixeldungeon.actors.hero.Belongings)2