Search in sources :

Example 1 with Crossbow

use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow in project shattered-pixel-dungeon-gdx by 00-Evan.

the class MissileSprite method setup.

// TODO it might be nice to have a source and destination angle, to improve thrown weapon visuals
private void setup(PointF from, PointF to, Item item, Callback listener) {
    originToCenter();
    this.callback = listener;
    point(from);
    PointF d = PointF.diff(to, from);
    speed.set(d).normalize().scale(SPEED);
    angularSpeed = DEFAULT_ANGULAR_SPEED;
    for (Class<? extends Item> cls : ANGULAR_SPEEDS.keySet()) {
        if (cls.isAssignableFrom(item.getClass())) {
            angularSpeed = ANGULAR_SPEEDS.get(cls);
            break;
        }
    }
    angle = 135 - (float) (Math.atan2(d.x, d.y) / 3.1415926 * 180);
    if (d.x >= 0) {
        flipHorizontal = false;
        updateFrame();
    } else {
        angularSpeed = -angularSpeed;
        angle += 90;
        flipHorizontal = true;
        updateFrame();
    }
    float speed = SPEED;
    if (item instanceof Dart && Dungeon.hero.belongings.weapon instanceof Crossbow) {
        speed *= 3f;
    }
    PosTweener tweener = new PosTweener(this, to, d.length() / speed);
    tweener.listener = this;
    parent.add(tweener);
}
Also used : Crossbow(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow) PosTweener(com.watabou.noosa.tweeners.PosTweener) PointF(com.watabou.utils.PointF) Dart(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)

Aggregations

Crossbow (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow)1 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)1 PosTweener (com.watabou.noosa.tweeners.PosTweener)1 PointF (com.watabou.utils.PointF)1