Search in sources :

Example 21 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

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);
        new Gold(item.price()).doPickUp(hero);
        // selling items in the sell interface doesn't spend time
        hero.spend(-hero.cooldown());
    }
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 22 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndTradeItem method buy.

private void buy(Heap heap) {
    Hero hero = Dungeon.hero;
    Item item = heap.pickUp();
    int price = price(item);
    Dungeon.gold -= price;
    if (!item.doPickUp(hero)) {
        Dungeon.level.drop(item, heap.pos).sprite.drop();
    }
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 23 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Char method attack.

public boolean attack(Char enemy) {
    if (enemy == null || !enemy.isAlive())
        return false;
    boolean visibleFight = Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[enemy.pos];
    if (hit(this, enemy, false)) {
        int dr = enemy.drRoll();
        if (this instanceof Hero) {
            Hero h = (Hero) this;
            if (h.belongings.weapon instanceof MissileWeapon && h.subClass == HeroSubClass.SNIPER) {
                dr = 0;
            }
        }
        int dmg;
        Preparation prep = buff(Preparation.class);
        if (prep != null) {
            dmg = prep.damageRoll(this, enemy);
        } else {
            dmg = damageRoll();
        }
        int effectiveDamage = Math.max(dmg - dr, 0);
        effectiveDamage = attackProc(enemy, effectiveDamage);
        effectiveDamage = enemy.defenseProc(this, effectiveDamage);
        if (visibleFight) {
            Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
        }
        if (enemy == Dungeon.hero) {
            Dungeon.hero.interrupt();
        }
        // This matters as defence procs can sometimes inflict self-damage, such as armor glyphs.
        if (!enemy.isAlive()) {
            return true;
        }
        // TODO: consider revisiting this and shaking in more cases.
        float shake = 0f;
        if (enemy == Dungeon.hero)
            shake = effectiveDamage / (enemy.HT / 4);
        if (shake > 1f)
            Camera.main.shake(GameMath.gate(1, shake, 5), 0.3f);
        enemy.damage(effectiveDamage, this);
        if (buff(FireImbue.class) != null)
            buff(FireImbue.class).proc(enemy);
        if (buff(EarthImbue.class) != null)
            buff(EarthImbue.class).proc(enemy);
        enemy.sprite.bloodBurstA(sprite.center(), effectiveDamage);
        enemy.sprite.flash();
        if (!enemy.isAlive() && visibleFight) {
            if (enemy == Dungeon.hero) {
                Dungeon.fail(getClass());
                GLog.n(Messages.capitalize(Messages.get(Char.class, "kill", name)));
            } else if (this == Dungeon.hero) {
                GLog.i(Messages.capitalize(Messages.get(Char.class, "defeat", enemy.name)));
            }
        }
        return true;
    } else {
        if (visibleFight) {
            String defense = enemy.defenseVerb();
            enemy.sprite.showStatus(CharSprite.NEUTRAL, defense);
            Sample.INSTANCE.play(Assets.SND_MISS);
        }
        return false;
    }
}
Also used : FireImbue(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue) Preparation(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Preparation) EarthImbue(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) MissileWeapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon)

Example 24 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Foliage method evolve.

@Override
protected void evolve() {
    int[] map = Dungeon.level.map;
    boolean visible = false;
    int cell;
    for (int i = area.left; i < area.right; i++) {
        for (int j = area.top; j < area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0) {
                off[cell] = cur[cell];
                volume += off[cell];
                if (map[cell] == Terrain.EMBERS) {
                    map[cell] = Terrain.GRASS;
                    GameScene.updateMap(cell);
                }
                visible = visible || Dungeon.level.heroFOV[cell];
            } else {
                off[cell] = 0;
            }
        }
    }
    Hero hero = Dungeon.hero;
    if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) {
        Buff.affect(hero, Shadows.class).prolong();
    }
    if (visible) {
        Notes.add(Notes.Landmark.GARDEN);
    }
}
Also used : Shadows(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)

Example 25 with Hero

use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Combo method getIcon.

@Override
public Image getIcon() {
    Image icon;
    if (((Hero) target).belongings.weapon != null) {
        icon = new ItemSprite(((Hero) target).belongings.weapon.image, null);
    } else {
        icon = new ItemSprite(new Item() {

            {
                image = ItemSpriteSheet.WEAPON_HOLDER;
            }
        });
    }
    if (count >= 10)
        icon.tint(0xFFFF0000);
    else if (count >= 8)
        icon.tint(0xFFFFCC00);
    else if (count >= 6)
        icon.tint(0xFFFFFF00);
    else if (count >= 4)
        icon.tint(0xFFCCFF00);
    else
        icon.tint(0xFF00FF00);
    return icon;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) ItemSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite) Image(com.watabou.noosa.Image)

Aggregations

Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)25 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)9 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)8 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)5 ArrayList (java.util.ArrayList)4 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)3 Barkskin (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin)2 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)2 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)2 KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat)2 Knuckles (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles)2 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)1 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)1 Bleeding (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding)1 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 EarthImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue)1 FireImbue (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue)1 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)1