use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart in project shattered-pixel-dungeon-gdx by 00-Evan.
the class ScorpioSprite method onComplete.
@Override
public void onComplete(Animation anim) {
if (anim == zap) {
idle();
((MissileSprite) parent.recycle(MissileSprite.class)).reset(ch.pos, cellToAttack, new Dart(), new Callback() {
@Override
public void call() {
ch.onAttackComplete();
}
});
} else {
super.onComplete(anim);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WornDartTrap method activate.
@Override
public void activate() {
Char target = Actor.findChar(pos);
// find the closest char that can be aimed at
if (target == null) {
for (Char ch : Actor.chars()) {
Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
target = ch;
}
}
}
if (target != null) {
final Char finalTarget = target;
final WornDartTrap trap = this;
if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
Actor.add(new Actor() {
{
// it's a visual effect, gets priority no matter what
actPriority = VFX_PRIO;
}
@Override
protected boolean act() {
final Actor toRemove = this;
((MissileSprite) ShatteredPixelDungeon.scene().recycle(MissileSprite.class)).reset(pos, finalTarget.sprite, new Dart(), new Callback() {
@Override
public void call() {
int dmg = Random.NormalIntRange(1, 4) - finalTarget.drRoll();
finalTarget.damage(dmg, trap);
if (finalTarget == Dungeon.hero && !finalTarget.isAlive()) {
Dungeon.fail(trap.getClass());
}
Sample.INSTANCE.play(Assets.SND_HIT, 1, 1, Random.Float(0.8f, 1.25f));
finalTarget.sprite.bloodBurstA(finalTarget.sprite.center(), dmg);
finalTarget.sprite.flash();
Actor.remove(toRemove);
next();
}
});
return false;
}
});
} else {
finalTarget.damage(Random.NormalIntRange(1, 4) - finalTarget.drRoll(), trap);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart 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);
}
Aggregations