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);
}
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;
}
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);
}
}
}
}
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();
}
Aggregations