use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class LootIndicator method update.
@Override
public void update() {
if (Dungeon.hero.ready) {
Heap heap = Dungeon.level.heaps.get(Dungeon.hero.pos);
if (heap != null && heap.type != Heap.Type.HIDDEN) {
Item item = heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST : heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST : heap.type == Heap.Type.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : heap.peek();
if (item != lastItem || item.quantity() != lastQuantity) {
lastItem = item;
lastQuantity = item.quantity();
slot.item(item);
flash();
}
visible = true;
} else {
lastItem = null;
visible = false;
}
}
slot.enable(visible && Dungeon.hero.ready);
super.update();
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class WndBag method placeItems.
protected void placeItems(Bag container) {
// Equipped items
Belongings stuff = Dungeon.hero.belongings;
placeItem(stuff.weapon != null ? stuff.weapon : new Placeholder(ItemSpriteSheet.WEAPON));
placeItem(stuff.armor != null ? stuff.armor : new Placeholder(ItemSpriteSheet.ARMOR));
placeItem(stuff.ring1 != null ? stuff.ring1 : new Placeholder(ItemSpriteSheet.RING));
placeItem(stuff.ring2 != null ? stuff.ring2 : new Placeholder(ItemSpriteSheet.RING));
boolean backpack = (container == Dungeon.hero.belongings.backpack);
if (!backpack) {
count = nCols;
col = 0;
row = 1;
}
// Items in the bag
for (Item item : container.items) {
placeItem(item);
}
// Free space
while (count - (backpack ? 4 : nCols) < container.size) {
placeItem(null);
}
// Gold in the backpack
if (container == Dungeon.hero.belongings.backpack) {
row = nRows - 1;
col = nCols - 1;
placeItem(new Gold(Dungeon.gold));
}
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
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;
GLog.i(TXT_BOUGHT, item.name(), price);
if (!item.doPickUp(hero)) {
Dungeon.level.drop(item, heap.pos).sprite.drop();
}
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class WndWandmaker method onSelect.
@Override
protected void onSelect(int index) {
questItem.detach(Dungeon.hero.belongings.backpack);
Item reward = index == 0 ? Wandmaker.Quest.wand1 : Wandmaker.Quest.wand2;
reward.identify();
if (reward.doPickUp(Dungeon.hero)) {
GLog.i(Hero.TXT_YOU_NOW_HAVE, reward.name());
} else {
Dungeon.level.drop(reward, wandmaker.pos).sprite.drop();
}
wandmaker.yell(Utils.format(TXT_FARAWELL, Dungeon.hero.className()));
wandmaker.destroy();
wandmaker.sprite.die();
Wandmaker.Quest.complete();
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class WellWater method affect.
protected boolean affect() {
Heap heap;
if (pos == Dungeon.hero.pos && affectHero(Dungeon.hero)) {
volume = off[pos] = cur[pos] = 0;
return true;
} else if ((heap = Dungeon.level.heaps.get(pos)) != null) {
Item oldItem = heap.peek();
Item newItem = affectItem(oldItem);
if (newItem != null) {
if (newItem == oldItem) {
} else if (oldItem.quantity() > 1) {
oldItem.quantity(oldItem.quantity() - 1);
heap.drop(newItem);
} else {
heap.replace(oldItem, newItem);
}
heap.sprite.link();
volume = off[pos] = cur[pos] = 0;
return true;
} else {
int newPlace;
do {
newPlace = pos + Level.NEIGHBOURS8[Random.Int(8)];
} while (!Level.passable[newPlace] && !Level.avoid[newPlace]);
Dungeon.level.drop(heap.pickUp(), newPlace).sprite.drop(pos);
return false;
}
} else {
return false;
}
}
Aggregations