Search in sources :

Example 1 with Ring

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;
        }
    }
}
Also used : InputStream(java.io.InputStream) Bundle(com.watabou.utils.Bundle) Ring(com.watabou.pixeldungeon.items.rings.Ring) IOException(java.io.IOException)

Example 2 with Ring

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;
}
Also used : Ring(com.watabou.pixeldungeon.items.rings.Ring)

Example 3 with Ring

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);
            }
        }
    }
}
Also used : Armor(com.watabou.pixeldungeon.items.armor.Armor) Ring(com.watabou.pixeldungeon.items.rings.Ring) PointF(com.watabou.utils.PointF) Wand(com.watabou.pixeldungeon.items.wands.Wand) CharSprite(com.watabou.pixeldungeon.sprites.CharSprite) Weapon(com.watabou.pixeldungeon.items.weapon.Weapon) MissileWeapon(com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)

Aggregations

Ring (com.watabou.pixeldungeon.items.rings.Ring)3 Armor (com.watabou.pixeldungeon.items.armor.Armor)1 Wand (com.watabou.pixeldungeon.items.wands.Wand)1 Weapon (com.watabou.pixeldungeon.items.weapon.Weapon)1 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)1 CharSprite (com.watabou.pixeldungeon.sprites.CharSprite)1 Bundle (com.watabou.utils.Bundle)1 PointF (com.watabou.utils.PointF)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1