use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
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) {
// Keep unique items
} else if (!item.isEquipped(owner)) {
item.detachAll(backpack);
}
}
if (weapon != null) {
weapon.cursed = false;
weapon.activate(owner);
}
if (armor != null) {
armor.cursed = false;
}
if (ring1 != null) {
ring1.cursed = false;
ring1.activate(owner);
}
if (ring2 != null) {
ring2.cursed = false;
ring2.activate(owner);
}
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class Hero method actPickUp.
private boolean actPickUp(HeroAction.PickUp action) {
int dst = action.dst;
if (pos == dst) {
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
Item item = heap.pickUp();
if (item.doPickUp(this)) {
if (item instanceof Dewdrop) {
// Do nothing
} else {
boolean important = ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll) item).isKnown()) || ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion) item).isKnown());
if (important) {
GLog.p(TXT_YOU_NOW_HAVE, item.name());
} else {
GLog.i(TXT_YOU_NOW_HAVE, item.name());
}
}
if (!heap.isEmpty()) {
GLog.i(TXT_SOMETHING_ELSE);
}
curAction = null;
} else {
Dungeon.level.drop(item, pos).sprite.drop();
ready();
}
} else {
ready();
}
return false;
} else if (getCloser(dst)) {
return true;
} else {
ready();
return false;
}
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon-remix by NYRDS.
the class NecroBossLevel 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 VaultPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.EMPTY);
int cx = (room.left + room.right) / 2;
int cy = (room.top + room.bottom) / 2;
int c = cx + cy * level.getWidth();
switch(Random.Int(3)) {
case 0:
level.drop(prize(level), c).type = Type.LOCKED_CHEST;
level.addItemToSpawn(new GoldenKey());
break;
case 1:
Item i1, i2;
do {
i1 = prize(level);
i2 = prize(level);
} while (i1.getClass() == i2.getClass());
level.drop(i1, c).type = Type.CRYSTAL_CHEST;
level.drop(i2, c + Level.NEIGHBOURS8[Random.Int(8)]).type = Type.CRYSTAL_CHEST;
level.addItemToSpawn(new GoldenKey());
break;
case 2:
level.drop(prize(level), c);
set(level, c, Terrain.PEDESTAL);
break;
}
room.entrance().set(Room.Door.Type.LOCKED);
level.addItemToSpawn(new IronKey());
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon-remix by NYRDS.
the class PoolPainter method prize.
private static Item prize(Level level) {
Item prize = level.itemToSpanAsPrize();
if (prize != null) {
return prize;
}
prize = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR));
for (int i = 0; i < 4; i++) {
Item another = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR));
if (another.level() > prize.level()) {
prize = another;
}
}
return prize;
}
Aggregations