use of com.watabou.pixeldungeon.items.rings.Ring in project pixel-dungeon by watabou.
the class Bones method get.
public static Item get() {
if (depth == -1) {
try {
InputStream input = Game.instance.openFileInput(BONES_FILE);
Bundle bundle = Bundle.read(input);
input.close();
depth = bundle.getInt(LEVEL);
item = (Item) bundle.get(ITEM);
return get();
} catch (IOException e) {
return null;
}
} else {
if (depth == Dungeon.depth) {
Game.instance.deleteFile(BONES_FILE);
depth = 0;
if (!item.stackable) {
item.cursed = true;
item.cursedKnown = true;
if (item.isUpgradable()) {
int lvl = (Dungeon.depth - 1) * 3 / 5 + 1;
if (lvl < item.level()) {
item.degrade(item.level() - lvl);
}
item.levelKnown = false;
}
}
if (item instanceof Ring) {
((Ring) item).syncGem();
}
return item;
} else {
return null;
}
}
}
use of com.watabou.pixeldungeon.items.rings.Ring in project pixel-dungeon by watabou.
the class WaterOfTransmutation method changeRing.
private Ring changeRing(Ring r) {
Ring n;
do {
n = (Ring) Generator.random(Category.RING);
} while (n.getClass() == r.getClass());
n.level(0);
int level = r.level();
if (level > 0) {
n.upgrade(level);
} else if (level < 0) {
n.degrade(-level);
}
n.levelKnown = r.levelKnown;
n.cursedKnown = r.cursedKnown;
n.cursed = r.cursed;
return n;
}
use of com.watabou.pixeldungeon.items.rings.Ring in project pixel-dungeon by watabou.
the class Item method use.
public void use() {
if (level > 0 && !isBroken()) {
int threshold = (int) (maxDurability() * DURABILITY_WARNING_LEVEL);
if (durability-- >= threshold && threshold > durability && levelKnown) {
GLog.w(TXT_GONNA_BREAK, name());
}
if (isBroken()) {
getBroken();
if (levelKnown) {
GLog.n(TXT_BROKEN, name());
Dungeon.hero.interrupt();
CharSprite sprite = Dungeon.hero.sprite;
PointF point = sprite.center().offset(0, -16);
if (this instanceof Weapon) {
sprite.parent.add(Degradation.weapon(point));
} else if (this instanceof Armor) {
sprite.parent.add(Degradation.armor(point));
} else if (this instanceof Ring) {
sprite.parent.add(Degradation.ring(point));
} else if (this instanceof Wand) {
sprite.parent.add(Degradation.wand(point));
}
Sample.INSTANCE.play(Assets.SND_DEGRADE);
}
}
}
}
Aggregations