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;
}
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();
}
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;
}
}
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));
}
}
}
}
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());
}
Aggregations