Search in sources :

Example 21 with Hero

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;
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) Hero(com.watabou.pixeldungeon.actors.hero.Hero) Level(com.watabou.pixeldungeon.levels.Level)

Example 22 with Hero

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);
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Hero(com.watabou.pixeldungeon.actors.hero.Hero) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem)

Example 23 with Hero

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);
    }
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 24 with Hero

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);
}
Also used : Item(com.watabou.pixeldungeon.items.Item) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem) Gold(com.watabou.pixeldungeon.items.Gold) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 25 with Hero

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);
}
Also used : Item(com.watabou.pixeldungeon.items.Item) MasteryItem(com.nyrds.pixeldungeon.items.common.MasteryItem) Hero(com.watabou.pixeldungeon.actors.hero.Hero) RedButton(com.watabou.pixeldungeon.ui.RedButton) BlackSkull(com.nyrds.pixeldungeon.items.necropolis.BlackSkull)

Aggregations

Hero (com.watabou.pixeldungeon.actors.hero.Hero)44 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)8 Item (com.watabou.pixeldungeon.items.Item)8 Char (com.watabou.pixeldungeon.actors.Char)6 Gold (com.watabou.pixeldungeon.items.Gold)5 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)4 BlackSkull (com.nyrds.pixeldungeon.items.necropolis.BlackSkull)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)2 Barkskin (com.watabou.pixeldungeon.actors.buffs.Barkskin)2 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)2 Thief (com.watabou.pixeldungeon.actors.mobs.Thief)2 Dewdrop (com.watabou.pixeldungeon.items.Dewdrop)2 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.watabou.pixeldungeon.items.food.MysteryMeat)2 Herbalism (com.watabou.pixeldungeon.items.rings.RingOfHerbalism.Herbalism)2 RingOfSatiety (com.watabou.pixeldungeon.items.rings.RingOfSatiety)2 Knuckles (com.watabou.pixeldungeon.items.weapon.melee.Knuckles)2 Level (com.watabou.pixeldungeon.levels.Level)2 SuppressLint (android.annotation.SuppressLint)1 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1