use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class Mob method chooseNearestEnemyFromFraction.
private Char chooseNearestEnemyFromFraction(Fraction enemyFraction) {
Level level = Dungeon.level;
Char bestEnemy = DUMMY;
float dist = level.getWidth() + level.getHeight();
if (enemyFraction.belongsTo(Fraction.HEROES)) {
Hero hero = Dungeon.hero;
if (!friendly(hero)) {
bestEnemy = hero;
dist = level.distanceL2(getPos(), bestEnemy.getPos());
}
}
for (Mob mob : level.mobs) {
if (!mob.friendly(this)) {
float candidateDist = level.distanceL2(getPos(), mob.getPos());
if (candidateDist < dist) {
bestEnemy = mob;
dist = candidateDist;
}
}
}
return bestEnemy;
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class WndTradeItem method sell.
private void sell(Item item) {
Hero hero = Dungeon.hero;
if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
return;
}
item.detachAll(hero.belongings.backpack);
int price = item.price();
new Gold(price).doPickUp(hero);
GLog.i(TXT_SOLD, item.name(), price);
placeItemInShop(item);
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class WndTradeItem method sellOne.
private void sellOne(Item item) {
if (item.quantity() <= 1) {
sell(item);
} else {
Hero hero = Dungeon.hero;
item = item.detach(hero.belongings.backpack);
int price = item.price();
new Gold(price).doPickUp(hero);
GLog.i(TXT_SOLD, item.name(), price);
placeItemInShop(item);
}
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class WndTradeItem method buy.
private void buy(Heap heap) {
Hero hero = Dungeon.hero;
Item item = heap.pickUp();
int price = price(item);
Dungeon.gold(Dungeon.gold() - price);
GLog.i(TXT_BOUGHT, item.name(), price);
if (!item.doPickUp(hero)) {
Dungeon.level.drop(item, heap.pos).sprite.drop();
}
Item newItem;
do {
newItem = Generator.random();
} while (newItem instanceof Gold);
placeItemInShop(newItem);
}
use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.
the class WndChooseWay method btnBreakSpell.
private void btnBreakSpell(RedButton btnWay1) {
RedButton btnWay2 = new RedButton(Utils.capitalize(TXT_BREAK_SPELL_BTN)) {
@Override
protected void onClick() {
hide();
Hero hero = Dungeon.hero;
Item a = hero.belongings.getItem(BlackSkullOfMastery.class);
a.removeItemFrom(hero);
Item b = new BlackSkull();
Dungeon.level.drop(b, hero.getPos()).sprite.drop();
}
};
btnWay2.setRect(btnWay1.right() + GAP, btnWay1.top(), btnWay1.width(), BTN_HEIGHT);
add(btnWay2);
}
Aggregations