Search in sources :

Example 76 with Item

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

the class PredesignedLevel method createItems.

@Override
protected void createItems() {
    try {
        if (mLevelDesc.has("items")) {
            JSONArray itemsDesc = mLevelDesc.getJSONArray("items");
            for (int i = 0; i < itemsDesc.length(); ++i) {
                JSONObject itemDesc = itemsDesc.optJSONObject(i);
                int x = itemDesc.getInt("x");
                int y = itemDesc.getInt("y");
                if (cellValid(x, y)) {
                    Item item = ItemFactory.createItemFromDesc(itemDesc);
                    drop(item, cell(x, y));
                }
            }
        }
    } catch (JSONException e) {
        throw new TrackedRuntimeException("bad items description", e);
    } catch (Exception e) {
        throw new TrackedRuntimeException(e);
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONException(org.json.JSONException)

Example 77 with Item

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

the class TownShopLevel method makeShop.

private void makeShop() {
    ArrayList<Item> items = new ArrayList<>();
    items.add(new LeatherArmor().identify());
    items.add(new Dagger().identify());
    items.add(new Knuckles().identify());
    items.add(new Sword().identify());
    items.add(new Quarterstaff().identify());
    items.add(new TomeOfKnowledge().identify());
    for (int i = 0; i < 3; i++) {
        items.add(new OverpricedRation());
        items.add(new Dart(5).identify());
        items.add(new CommonArrow(25));
        items.add(new Torch().identify());
    }
    items.add(new Keyring());
    items.add(new ScrollHolder());
    items.add(new PotionBelt());
    items.add(new SeedPouch());
    items.add(new Quiver());
    items.add(new WandHolster());
    Item[] range = items.toArray(new Item[items.size()]);
    for (Item item : range) {
        itemForSell(item);
    }
}
Also used : Keyring(com.watabou.pixeldungeon.items.bags.Keyring) Quiver(com.watabou.pixeldungeon.items.bags.Quiver) TomeOfKnowledge(com.nyrds.pixeldungeon.items.books.TomeOfKnowledge) ArrayList(java.util.ArrayList) ScrollHolder(com.watabou.pixeldungeon.items.bags.ScrollHolder) Quarterstaff(com.watabou.pixeldungeon.items.weapon.melee.Quarterstaff) Torch(com.watabou.pixeldungeon.items.Torch) WandHolster(com.watabou.pixeldungeon.items.bags.WandHolster) Item(com.watabou.pixeldungeon.items.Item) Knuckles(com.watabou.pixeldungeon.items.weapon.melee.Knuckles) PotionBelt(com.watabou.pixeldungeon.items.bags.PotionBelt) Sword(com.watabou.pixeldungeon.items.weapon.melee.Sword) OverpricedRation(com.watabou.pixeldungeon.items.food.OverpricedRation) CommonArrow(com.watabou.pixeldungeon.items.weapon.missiles.CommonArrow) SeedPouch(com.watabou.pixeldungeon.items.bags.SeedPouch) LeatherArmor(com.watabou.pixeldungeon.items.armor.LeatherArmor) Dagger(com.watabou.pixeldungeon.items.weapon.melee.Dagger) Dart(com.watabou.pixeldungeon.items.weapon.missiles.Dart)

Example 78 with Item

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

the class CagedKobold method interact.

@Override
public boolean interact(final Hero hero) {
    getSprite().turnTo(getPos(), hero.getPos());
    if (Quest.completed) {
        return true;
    }
    if (Quest.given) {
        Item item = hero.belongings.getItem(IceKey.class);
        if (item != null) {
            item.removeItemFrom(Dungeon.hero);
            Item reward = new CandleOfMindVision();
            if (reward.doPickUp(Dungeon.hero)) {
                GLog.i(Hero.TXT_YOU_NOW_HAVE, reward.name());
            } else {
                Dungeon.level.drop(reward, hero.getPos()).sprite.drop();
            }
            Quest.complete();
            GameScene.show(new WndQuest(this, TXT_QUEST_END));
            CellEmitter.get(getPos()).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
            getSprite().killAndErase();
            destroy();
        } else {
            int index = Random.Int(0, TXT_PHRASES.length);
            say(TXT_PHRASES[index]);
        }
    } else {
        GameScene.show(new WndQuest(this, TXT_QUEST_START));
        Quest.given = true;
        Quest.process();
        Journal.add(Journal.Feature.CAGEDKOBOLD.desc());
    }
    return true;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) WndQuest(com.watabou.pixeldungeon.windows.WndQuest) CandleOfMindVision(com.nyrds.pixeldungeon.items.artifacts.CandleOfMindVision)

Example 79 with Item

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

the class UpgradablePotion method upgrade.

@Override
public Item upgrade() {
    if (getCurUser() != null && quantity() > 1) {
        Item potion = detach(getCurUser().belongings.backpack);
        getCurUser().collect(potion.upgrade());
        return this;
    }
    return super.upgrade();
}
Also used : Item(com.watabou.pixeldungeon.items.Item)

Example 80 with Item

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

the class UpgradablePotion method degrade.

@Override
public Item degrade() {
    if (getCurUser() != null && quantity() > 1) {
        Item potion = detach(getCurUser().belongings.backpack);
        getCurUser().collect(potion.degrade());
        return this;
    }
    return super.degrade();
}
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