Search in sources :

Example 1 with MissileSprite

use of com.watabou.pixeldungeon.sprites.MissileSprite in project pixel-dungeon by watabou.

the class HuntressArmor method doSpecial.

@Override
public void doSpecial() {
    Item proto = new Shuriken();
    for (Mob mob : Dungeon.level.mobs) {
        if (Level.fieldOfView[mob.pos]) {
            Callback callback = new Callback() {

                @Override
                public void call() {
                    curUser.attack(targets.get(this));
                    targets.remove(this);
                    if (targets.isEmpty()) {
                        curUser.spendAndNext(curUser.attackDelay());
                    }
                }
            };
            ((MissileSprite) curUser.sprite.parent.recycle(MissileSprite.class)).reset(curUser.pos, mob.pos, proto, callback);
            targets.put(callback, mob);
        }
    }
    if (targets.size() == 0) {
        GLog.w(TXT_NO_ENEMIES);
        return;
    }
    curUser.HP -= (curUser.HP / 3);
    curUser.sprite.zap(curUser.pos);
    curUser.busy();
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Callback(com.watabou.utils.Callback) Shuriken(com.watabou.pixeldungeon.items.weapon.missiles.Shuriken) MissileSprite(com.watabou.pixeldungeon.sprites.MissileSprite)

Example 2 with MissileSprite

use of com.watabou.pixeldungeon.sprites.MissileSprite in project pixel-dungeon by watabou.

the class Item method cast.

public void cast(final Hero user, int dst) {
    final int cell = Ballistica.cast(user.pos, dst, false, true);
    user.sprite.zap(cell);
    user.busy();
    Sample.INSTANCE.play(Assets.SND_MISS, 0.6f, 0.6f, 1.5f);
    Char enemy = Actor.findChar(cell);
    QuickSlot.target(this, enemy);
    // FIXME!!!
    float delay = TIME_TO_THROW;
    if (this instanceof MissileWeapon) {
        delay *= ((MissileWeapon) this).speedFactor(user);
        if (enemy != null) {
            SnipersMark mark = user.buff(SnipersMark.class);
            if (mark != null) {
                if (mark.object == enemy.id()) {
                    delay *= 0.5f;
                }
                user.remove(mark);
            }
        }
    }
    final float finalDelay = delay;
    ((MissileSprite) user.sprite.parent.recycle(MissileSprite.class)).reset(user.pos, cell, this, new Callback() {

        @Override
        public void call() {
            Item.this.detach(user.belongings.backpack).onThrow(cell);
            user.spendAndNext(finalDelay);
        }
    });
}
Also used : SnipersMark(com.watabou.pixeldungeon.actors.buffs.SnipersMark) Callback(com.watabou.utils.Callback) Char(com.watabou.pixeldungeon.actors.Char) MissileWeapon(com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon) MissileSprite(com.watabou.pixeldungeon.sprites.MissileSprite)

Aggregations

MissileSprite (com.watabou.pixeldungeon.sprites.MissileSprite)2 Callback (com.watabou.utils.Callback)2 Char (com.watabou.pixeldungeon.actors.Char)1 SnipersMark (com.watabou.pixeldungeon.actors.buffs.SnipersMark)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Item (com.watabou.pixeldungeon.items.Item)1 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)1 Shuriken (com.watabou.pixeldungeon.items.weapon.missiles.Shuriken)1