use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WarlockSprite method zap.
public void zap(int cell) {
turnTo(ch.pos, cell);
play(zap);
MagicMissile.boltFromChar(parent, MagicMissile.SHADOW, this, cell, new Callback() {
@Override
public void call() {
((Warlock) ch).onZapComplete();
}
});
Sample.INSTANCE.play(Assets.SND_ZAP);
}
use of com.watabou.utils.Callback 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.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class BadgesScene method create.
@Override
public void create() {
super.create();
Music.INSTANCE.play(Assets.THEME, true);
uiCamera.visible = false;
int w = Camera.main.width;
int h = Camera.main.height;
Archs archs = new Archs();
archs.setSize(w, h);
add(archs);
float left = 5;
float top = 16;
RenderedText title = PixelScene.renderText(Messages.get(this, "title"), 9);
title.hardlight(Window.TITLE_COLOR);
title.x = (w - title.width()) / 2f;
title.y = (top - title.baseLine()) / 2f;
align(title);
add(title);
Badges.loadGlobal();
List<Badges.Badge> badges = Badges.filtered(true);
int blankBadges = 34;
blankBadges -= badges.size();
if (badges.contains(Badges.Badge.ALL_ITEMS_IDENTIFIED))
blankBadges -= 6;
if (badges.contains(Badges.Badge.YASD))
blankBadges -= 5;
blankBadges = Math.max(0, blankBadges);
// guarantees a max of 5 rows in landscape, and 8 in portrait, assuming a max of 40 buttons
int nCols = SPDSettings.landscape() ? 7 : 4;
if (badges.size() + blankBadges > 32 && !SPDSettings.landscape())
nCols++;
int nRows = 1 + (blankBadges + badges.size()) / nCols;
float badgeWidth = (w - 2 * left) / nCols;
float badgeHeight = (h - 2 * top) / nRows;
for (int i = 0; i < badges.size() + blankBadges; i++) {
int row = i / nCols;
int col = i % nCols;
Badges.Badge b = i < badges.size() ? badges.get(i) : null;
BadgeButton button = new BadgeButton(b);
button.setPos(left + col * badgeWidth + (badgeWidth - button.width()) / 2, top + row * badgeHeight + (badgeHeight - button.height()) / 2);
align(button);
add(button);
}
ExitButton btnExit = new ExitButton();
btnExit.setPos(Camera.main.width - btnExit.width(), 0);
add(btnExit);
fadeIn();
Badges.loadingListener = new Callback() {
@Override
public void call() {
if (Game.scene() == BadgesScene.this) {
ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
}
}
};
}
use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class GrimTrap 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 GrimTrap trap = this;
int damage;
// almost kill the player
if (finalTarget == Dungeon.hero && ((float) finalTarget.HP / finalTarget.HT) >= 0.9f) {
damage = finalTarget.HP - 1;
// kill 'em
} else {
damage = finalTarget.HP;
}
final int finalDmg = damage;
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;
((MagicMissile) finalTarget.sprite.parent.recycle(MagicMissile.class)).reset(MagicMissile.SHADOW, DungeonTilemap.tileCenterToWorld(pos), finalTarget.sprite.center(), new Callback() {
@Override
public void call() {
finalTarget.damage(finalDmg, trap);
if (finalTarget == Dungeon.hero) {
Sample.INSTANCE.play(Assets.SND_CURSED);
if (!finalTarget.isAlive()) {
Dungeon.fail(GrimTrap.class);
GLog.n(Messages.get(GrimTrap.class, "ondeath"));
}
} else {
Sample.INSTANCE.play(Assets.SND_BURNING);
}
finalTarget.sprite.emitter().burst(ShadowParticle.UP, 10);
Actor.remove(toRemove);
next();
}
});
return false;
}
});
} else {
CellEmitter.get(pos).burst(ShadowParticle.UP, 10);
Sample.INSTANCE.play(Assets.SND_BURNING);
}
}
use of com.watabou.utils.Callback 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);
}
}
}
Aggregations