Search in sources :

Example 36 with Item

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

the class ScarecrowNPC method interact.

@Override
public boolean interact(final Hero hero) {
    getSprite().turnTo(getPos(), hero.getPos());
    if (Quest.completed) {
        this.die(null);
        return true;
    }
    if (Quest.given) {
        Item item = hero.belongings.getItem(Candy.class);
        if (item != null && item.quantity() == 5) {
            item.removeItemFrom(Dungeon.hero);
            Item reward = new PumpkinPie();
            reward.quantity(5);
            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));
        } else {
            GameScene.show(new WndQuest(this, TXT_QUEST));
        }
    } else {
        String txtQuestStart = TXT_QUEST_START_M;
        if (Dungeon.hero.getGender() == Utils.FEMININE) {
            txtQuestStart = TXT_QUEST_START_F;
        }
        GameScene.show(new WndQuest(this, txtQuestStart));
        Quest.given = true;
        Quest.process(hero.getPos());
        Journal.add(Journal.Feature.SCARECROW.desc());
    }
    return true;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) WndTradeItem(com.watabou.pixeldungeon.windows.WndTradeItem) PumpkinPie(com.nyrds.pixeldungeon.items.food.PumpkinPie) WndQuest(com.watabou.pixeldungeon.windows.WndQuest)

Example 37 with Item

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

the class RandomLevel method create.

@Override
public void create(int w, int h) {
    try {
        width = mLevelDesc.getInt("width");
        height = mLevelDesc.getInt("height");
        initSizeDependentStuff();
        feeling = DungeonGenerator.getLevelFeeling(levelId);
        if (mLevelDesc.has("items")) {
            JSONArray itemsDesc = mLevelDesc.getJSONArray("items");
            for (int i = 0; i < itemsDesc.length(); ++i) {
                JSONObject itemDesc = itemsDesc.optJSONObject(i);
                Item item = ItemFactory.createItemFromDesc(itemDesc);
                addItemToSpawn(item);
            }
        }
    } catch (JSONException e) {
        throw new TrackedRuntimeException(e);
    } catch (InstantiationException e) {
        throw new TrackedRuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new TrackedRuntimeException(e);
    }
    do {
        Arrays.fill(map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
    } while (!build());
    buildFlagMaps();
    cleanWalls();
    createMobs();
    createItems();
    createScript();
}
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)

Example 38 with Item

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

the class IceCavesBossLevel 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 39 with Item

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

the class WarehousePainter method paint.

public static void paint(Level level, Room room) {
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Terrain.EMPTY_SP);
    Room.Door entrance = room.entrance();
    entrance.set(Room.Door.Type.HIDDEN);
    for (int i = room.left + 1; i < room.right; i++) {
        for (int j = room.top + 1; j < room.bottom; j++) {
            if (Math.random() < 0.5) {
                level.addLevelObject(new Barrel(level.cell(i, j)));
            } else {
                Item prize = Random.oneOf(Generator.random(Generator.Category.BULLETS), Generator.random(Generator.Category.THROWABLE));
                level.drop(prize, level.cell(i, j));
            }
        }
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Barrel(com.nyrds.pixeldungeon.levels.objects.Barrel) Room(com.watabou.pixeldungeon.levels.Room)

Example 40 with Item

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

the class Blacksmith method upgrade.

public static void upgrade(Item item1, Item item2) {
    Item first, second;
    if (item2.level() > item1.level()) {
        first = item2;
        second = item1;
    } else {
        first = item1;
        second = item2;
    }
    Sample.INSTANCE.play(Assets.SND_EVOKE);
    ScrollOfUpgrade.upgrade(Dungeon.hero);
    Item.evoke(Dungeon.hero);
    if (first.isEquipped(Dungeon.hero)) {
        ((EquipableItem) first).doUnequip(Dungeon.hero, true);
    }
    first.upgrade();
    GLog.p(TXT_LOOKS_BETTER, first.name());
    Dungeon.hero.spendAndNext(2f);
    Badges.validateItemLevelAcquired(first);
    if (second.isEquipped(Dungeon.hero)) {
        ((EquipableItem) second).doUnequip(Dungeon.hero, false);
    }
    second.detachAll(Dungeon.hero.belongings.backpack);
    Quest.reforged = true;
    Journal.remove(Journal.Feature.TROLL.desc());
}
Also used : Item(com.watabou.pixeldungeon.items.Item) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem)

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