use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class Level method itemToSpanAsPrize.
public Item itemToSpanAsPrize() {
if (Random.Int(itemsToSpawn.size() + 1) > 0) {
Item item = Random.element(itemsToSpawn);
itemsToSpawn.remove(item);
return item;
} else {
return null;
}
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class HuntressArmor method doSpecial.
@Override
public void doSpecial() {
Item proto = new Shuriken();
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Callback callback = new Callback() {
@Override
public void call() {
curUser.attack(targets.get(this));
targets.remove(this);
if (targets.isEmpty()) {
curUser.spendAndNext(curUser.attackDelay());
}
}
};
((MissileSprite) curUser.sprite.parent.recycle(MissileSprite.class)).reset(curUser.pos, mob.pos, proto, callback);
targets.put(callback, mob);
}
}
if (targets.size() == 0) {
GLog.w(TXT_NO_ENEMIES);
return;
}
curUser.HP -= (curUser.HP / 3);
curUser.sprite.zap(curUser.pos);
curUser.busy();
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
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;
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class RatKingPainter method addChest.
private static void addChest(Level level, int pos, int door) {
if (pos == door - 1 || pos == door + 1 || pos == door - Level.WIDTH || pos == door + Level.WIDTH) {
return;
}
Item prize;
switch(Random.Int(10)) {
case 0:
prize = Generator.random(Generator.Category.WEAPON);
if (prize instanceof MissileWeapon) {
prize.quantity(1);
} else {
prize.degrade(Random.Int(3));
}
break;
case 1:
prize = Generator.random(Generator.Category.ARMOR).degrade(Random.Int(3));
break;
default:
prize = new Gold(Random.IntRange(1, 5));
break;
}
level.drop(prize, pos).type = Heap.Type.CHEST;
}
use of com.watabou.pixeldungeon.items.Item in project pixel-dungeon by watabou.
the class CavesBossLevel method createItems.
@Override
protected void createItems() {
Item item = Bones.get();
if (item != null) {
int pos;
do {
pos = Random.IntRange(ROOM_LEFT, ROOM_RIGHT) + Random.IntRange(ROOM_TOP + 1, ROOM_BOTTOM) * WIDTH;
} while (pos == entrance || map[pos] == Terrain.SIGN);
drop(item, pos).type = Heap.Type.SKELETON;
}
}
Aggregations