Search in sources :

Example 66 with Item

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

the class Belongings method resurrect.

public void resurrect(int depth) {
    for (Item item : backpack.items.toArray(new Item[0])) {
        if (item instanceof Key) {
            if (((Key) item).depth == depth) {
                item.detachAll(backpack);
            }
        } else if (item.unique) {
        // Keep unique items
        } else if (!item.isEquipped(owner)) {
            item.detachAll(backpack);
        }
    }
    if (weapon != null) {
        weapon.cursed = false;
        weapon.activate(owner);
    }
    if (armor != null) {
        armor.cursed = false;
    }
    if (ring1 != null) {
        ring1.cursed = false;
        ring1.activate(owner);
    }
    if (ring2 != null) {
        ring2.cursed = false;
        ring2.activate(owner);
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) IronKey(com.watabou.pixeldungeon.items.keys.IronKey) Key(com.watabou.pixeldungeon.items.keys.Key)

Example 67 with Item

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

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

the class NecroBossLevel method createItems.

@Override
protected void createItems() {
    Item item = Bones.get();
    if (item != null) {
        int pos;
        do {
            pos = Random.IntRange(_Left() + 1, _Left() + HALL_WIDTH - 2) + Random.IntRange(TOP + HALL_HEIGHT + 1, TOP + HALL_HEIGHT + CHAMBER_HEIGHT) * getWidth();
        } while (pos == entrance);
        drop(item, pos).type = Heap.Type.SKELETON;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item)

Example 69 with Item

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

the class VaultPainter method paint.

public static void paint(Level level, Room room) {
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Terrain.EMPTY);
    int cx = (room.left + room.right) / 2;
    int cy = (room.top + room.bottom) / 2;
    int c = cx + cy * level.getWidth();
    switch(Random.Int(3)) {
        case 0:
            level.drop(prize(level), c).type = Type.LOCKED_CHEST;
            level.addItemToSpawn(new GoldenKey());
            break;
        case 1:
            Item i1, i2;
            do {
                i1 = prize(level);
                i2 = prize(level);
            } while (i1.getClass() == i2.getClass());
            level.drop(i1, c).type = Type.CRYSTAL_CHEST;
            level.drop(i2, c + Level.NEIGHBOURS8[Random.Int(8)]).type = Type.CRYSTAL_CHEST;
            level.addItemToSpawn(new GoldenKey());
            break;
        case 2:
            level.drop(prize(level), c);
            set(level, c, Terrain.PEDESTAL);
            break;
    }
    room.entrance().set(Room.Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey());
}
Also used : Item(com.watabou.pixeldungeon.items.Item) GoldenKey(com.watabou.pixeldungeon.items.keys.GoldenKey) IronKey(com.watabou.pixeldungeon.items.keys.IronKey)

Example 70 with Item

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

the class PoolPainter method prize.

private static Item prize(Level level) {
    Item prize = level.itemToSpanAsPrize();
    if (prize != null) {
        return prize;
    }
    prize = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR));
    for (int i = 0; i < 4; i++) {
        Item another = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR));
        if (another.level() > prize.level()) {
            prize = another;
        }
    }
    return prize;
}
Also used : Item(com.watabou.pixeldungeon.items.Item)

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