Search in sources :

Example 1 with Weapon

use of com.watabou.pixeldungeon.items.weapon.Weapon in project pixel-dungeon-remix by NYRDS.

the class ScrollOfWeaponUpgrade method onItemSelected.

@Override
protected void onItemSelected(Item item) {
    Weapon weapon = (Weapon) item;
    ScrollOfRemoveCurse.uncurse(Dungeon.hero, weapon);
    weapon.upgrade(true);
    GLog.p(TXT_LOOKS_BETTER, weapon.name());
    Badges.validateItemLevelAcquired(weapon);
    getCurUser().getSprite().emitter().start(Speck.factory(Speck.UP), 0.2f, 3);
}
Also used : Weapon(com.watabou.pixeldungeon.items.weapon.Weapon)

Example 2 with Weapon

use of com.watabou.pixeldungeon.items.weapon.Weapon in project pixel-dungeon-remix by NYRDS.

the class Generator method randomWeapon.

private static Weapon randomWeapon() throws Exception {
    int curStr = Hero.STARTING_STR + Dungeon.potionOfStrength;
    Category cat = Category.WEAPON;
    Weapon w1 = (Weapon) cat.random();
    Weapon w2 = (Weapon) cat.random();
    return Math.abs(curStr - w1.STR) < Math.abs(curStr - w2.STR) ? w1 : w2;
}
Also used : Weapon(com.watabou.pixeldungeon.items.weapon.Weapon) MissileWeapon(com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)

Example 3 with Weapon

use of com.watabou.pixeldungeon.items.weapon.Weapon 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)

Example 4 with Weapon

use of com.watabou.pixeldungeon.items.weapon.Weapon in project pixel-dungeon-remix by NYRDS.

the class ItemSlot method item.

public void item(Item item) {
    if (item == null) {
        active = false;
        icon.setVisible(false);
        emitter.setVisible(false);
        emitter.on = false;
        topLeft.setVisible(false);
        topRight.setVisible(false);
        bottomRight.setVisible(false);
        return;
    }
    active = true;
    icon.setVisible(true);
    topLeft.setVisible(true);
    topRight.setVisible(true);
    bottomRight.setVisible(true);
    icon.view(item);
    if (item.emitter() != null) {
        emitter.setVisible(true);
        emitter.pour(item.emitter(), item.emitterInterval());
    } else {
        emitter.setVisible(false);
        emitter.on = false;
    }
    topLeft.text(item.status());
    boolean isArmor = item instanceof Armor;
    boolean isWeapon = item instanceof Weapon;
    if (isArmor || isWeapon) {
        if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) {
            int str = isArmor ? ((Armor) item).STR : ((Weapon) item).STR;
            topRight.text(Utils.format(TXT_STRENGTH, str));
            if (str > Dungeon.hero.effectiveSTR()) {
                topRight.hardlight(DEGRADED);
            } else {
                topRight.resetColor();
            }
        } else {
            topRight.text(Utils.format(TXT_TYPICAL_STR, isArmor ? ((Armor) item).typicalSTR() : ((MeleeWeapon) item).typicalSTR()));
            topRight.hardlight(WARNING);
        }
        topRight.measure();
    } else {
        topRight.text(null);
    }
    int level = item.visiblyUpgraded();
    if (level != 0) {
        bottomRight.text(Utils.format(TXT_LEVEL, level));
        bottomRight.measure();
        bottomRight.hardlight(level > 0 ? UPGRADED : DEGRADED);
    } else {
        bottomRight.text(null);
    }
    if (item instanceof Artifact) {
        Artifact artifact = (Artifact) item;
        String text = artifact.getText();
        if (text != null) {
            topLeft.text(artifact.getText());
            topLeft.hardlight(artifact.getColor());
            topLeft.setVisible(true);
            topLeft.measure();
        }
    }
    layout();
}
Also used : MeleeWeapon(com.watabou.pixeldungeon.items.weapon.melee.MeleeWeapon) Armor(com.watabou.pixeldungeon.items.armor.Armor) Weapon(com.watabou.pixeldungeon.items.weapon.Weapon) MeleeWeapon(com.watabou.pixeldungeon.items.weapon.melee.MeleeWeapon) Artifact(com.watabou.pixeldungeon.items.rings.Artifact)

Aggregations

Weapon (com.watabou.pixeldungeon.items.weapon.Weapon)4 Armor (com.watabou.pixeldungeon.items.armor.Armor)2 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)2 Artifact (com.watabou.pixeldungeon.items.rings.Artifact)1 Ring (com.watabou.pixeldungeon.items.rings.Ring)1 Wand (com.watabou.pixeldungeon.items.wands.Wand)1 MeleeWeapon (com.watabou.pixeldungeon.items.weapon.melee.MeleeWeapon)1 CharSprite (com.watabou.pixeldungeon.sprites.CharSprite)1 PointF (com.watabou.utils.PointF)1