Search in sources :

Example 56 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

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;
    if (!item.doPickUp(hero)) {
        Dungeon.level.drop(item, heap.pos).sprite.drop();
    }
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 57 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

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) {
            item.detachAll(backpack);
            // you keep the bag itself, not its contents.
            if (item instanceof Bag) {
                ((Bag) item).clear();
            }
            item.collect();
        } else if (!item.isEquipped(owner)) {
            item.detachAll(backpack);
        }
    }
    if (weapon != null) {
        weapon.cursed = false;
        weapon.activate(owner);
    }
    if (armor != null) {
        armor.cursed = false;
        armor.activate(owner);
    }
    if (misc1 != null) {
        misc1.cursed = false;
        misc1.activate(owner);
    }
    if (misc2 != null) {
        misc2.cursed = false;
        misc2.activate(owner);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Bag(com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) SkeletonKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey) GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) Key(com.shatteredpixel.shatteredpixeldungeon.items.keys.Key)

Example 58 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Belongings method observe.

public void observe() {
    if (weapon != null) {
        weapon.identify();
        Badges.validateItemLevelAquired(weapon);
    }
    if (armor != null) {
        armor.identify();
        Badges.validateItemLevelAquired(armor);
    }
    if (misc1 != null) {
        misc1.identify();
        Badges.validateItemLevelAquired(misc1);
    }
    if (misc2 != null) {
        misc2.identify();
        Badges.validateItemLevelAquired(misc2);
    }
    for (Item item : backpack) {
        item.cursedKnown = true;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item)

Example 59 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Hero method die.

@Override
public void die(Object cause) {
    curAction = null;
    Ankh ankh = null;
    // look for ankhs in player inventory, prioritize ones which are blessed.
    for (Item item : belongings) {
        if (item instanceof Ankh) {
            if (ankh == null || ((Ankh) item).isBlessed()) {
                ankh = (Ankh) item;
            }
        }
    }
    if (ankh != null && ankh.isBlessed()) {
        this.HP = HT / 4;
        // ensures that you'll get to act first in almost any case, to prevent reviving and then instantly dieing again.
        Buff.detach(this, Paralysis.class);
        spend(-cooldown());
        new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f);
        CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
        ankh.detach(belongings.backpack);
        Sample.INSTANCE.play(Assets.SND_TELEPORT);
        GLog.w(Messages.get(this, "revive"));
        Statistics.ankhsUsed++;
        return;
    }
    Actor.fixTime();
    super.die(cause);
    if (ankh == null) {
        reallyDie(cause);
    } else {
        Dungeon.deleteGame(GamesInProgress.curSlot, false);
        GameScene.show(new WndResurrect(ankh, cause));
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) WndTradeItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem) WndResurrect(com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Ankh(com.shatteredpixel.shatteredpixeldungeon.items.Ankh)

Example 60 with Item

use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Electricity method evolve.

@Override
protected void evolve() {
    water = Dungeon.level.water;
    int cell;
    // spread first..
    for (int i = area.left - 1; i <= area.right; i++) {
        for (int j = area.top - 1; j <= area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0) {
                spreadFromCell(cell, cur[cell]);
            }
        }
    }
    // ..then decrement/shock
    for (int i = area.left - 1; i <= area.right; i++) {
        for (int j = area.top - 1; j <= area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0) {
                Char ch = Actor.findChar(cell);
                if (ch != null && !ch.isImmune(this.getClass())) {
                    Buff.prolong(ch, Paralysis.class, 1f);
                    if (cur[cell] % 2 == 1) {
                        ch.damage(Math.round(Random.Float(2 + Dungeon.depth / 5f)), this);
                    }
                }
                Heap h = Dungeon.level.heaps.get(cell);
                if (h != null) {
                    Item toShock = h.peek();
                    if (toShock instanceof Wand) {
                        ((Wand) toShock).gainCharge(0.333f);
                    } else if (toShock instanceof MagesStaff) {
                        ((MagesStaff) toShock).gainCharge(0.333f);
                    }
                }
                off[cell] = cur[cell] - 1;
                volume += off[cell];
            } else {
                off[cell] = 0;
            }
        }
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) MagesStaff(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff) Wand(com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Aggregations

Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)67 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)14 ArrayList (java.util.ArrayList)14 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)7 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)7 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)7 Point (com.watabou.utils.Point)7 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)6 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)5 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)4 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)4 WndTradeItem (com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem)4 Dewdrop (com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop)3 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)3 Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)2 Belongings (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings)2 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)2 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)2