use of com.watabou.utils.Callback in project pixel-dungeon by watabou.
the class HeroSprite method read.
public void read() {
animCallback = new Callback() {
@Override
public void call() {
idle();
ch.onOperateComplete();
}
};
play(read);
}
use of com.watabou.utils.Callback in project pixel-dungeon by watabou.
the class WarlockSprite method zap.
public void zap(int cell) {
turnTo(ch.pos, cell);
play(zap);
MagicMissile.shadow(parent, ch.pos, 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 Guard method chain.
private boolean chain(int target) {
if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))
return false;
Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE);
if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || Dungeon.level.pit[chain.path.get(1)])
return false;
else {
int newPos = -1;
for (int i : chain.subPath(1, chain.dist)) {
if (!Dungeon.level.solid[i] && Actor.findChar(i) == null) {
newPos = i;
break;
}
}
if (newPos == -1) {
return false;
} else {
final int newPosFinal = newPos;
this.target = newPos;
yell(Messages.get(this, "scorpion"));
sprite.parent.add(new Chains(sprite.center(), enemy.sprite.center(), new Callback() {
public void call() {
Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {
public void call() {
enemy.pos = newPosFinal;
Dungeon.level.press(newPosFinal, enemy, true);
Cripple.prolong(enemy, Cripple.class, 4f);
if (enemy == Dungeon.hero) {
Dungeon.hero.interrupt();
Dungeon.observe();
GameScene.updateFog();
}
}
}), -1);
next();
}
}));
}
}
chainsUsed = true;
return true;
}
use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class EtherealChains method chainLocation.
// pulls the hero along the chain to the collosionPos, if possible.
private void chainLocation(Ballistica chain, final Hero hero) {
// don't pull if the collision spot is in a wall
if (Dungeon.level.solid[chain.collisionPos]) {
GLog.i(Messages.get(this, "inside_wall"));
return;
}
// don't pull if there are no solid objects next to the pull location
boolean solidFound = false;
for (int i : PathFinder.NEIGHBOURS8) {
if (Dungeon.level.solid[chain.collisionPos + i]) {
solidFound = true;
break;
}
}
if (!solidFound) {
GLog.i(Messages.get(EtherealChains.class, "nothing_to_grab"));
return;
}
final int newHeroPos = chain.collisionPos;
int chargeUse = Dungeon.level.distance(hero.pos, newHeroPos);
if (chargeUse > charge) {
GLog.w(Messages.get(EtherealChains.class, "no_charge"));
return;
} else {
charge -= chargeUse;
updateQuickslot();
}
hero.busy();
hero.sprite.parent.add(new Chains(hero.sprite.center(), DungeonTilemap.raisedTileCenterToWorld(newHeroPos), new Callback() {
public void call() {
Actor.add(new Pushing(hero, hero.pos, newHeroPos, new Callback() {
public void call() {
Dungeon.level.press(newHeroPos, hero);
}
}));
hero.spendAndNext(1f);
hero.pos = newHeroPos;
Dungeon.observe();
GameScene.updateFog();
}
}));
}
use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Pickaxe method execute.
@Override
public void execute(final Hero hero, String action) {
super.execute(hero, action);
if (action.equals(AC_MINE)) {
if (Dungeon.depth < 11 || Dungeon.depth > 15) {
GLog.w(Messages.get(this, "no_vein"));
return;
}
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
final int pos = hero.pos + PathFinder.NEIGHBOURS8[i];
if (Dungeon.level.map[pos] == Terrain.WALL_DECO) {
hero.spend(TIME_TO_MINE);
hero.busy();
hero.sprite.attack(pos, new Callback() {
@Override
public void call() {
CellEmitter.center(pos).burst(Speck.factory(Speck.STAR), 7);
Sample.INSTANCE.play(Assets.SND_EVOKE);
Level.set(pos, Terrain.WALL);
GameScene.updateMap(pos);
DarkGold gold = new DarkGold();
if (gold.doPickUp(Dungeon.hero)) {
GLog.i(Messages.get(Dungeon.hero, "you_now_have", gold.name()));
} else {
Dungeon.level.drop(gold, hero.pos).sprite.drop();
}
hero.onOperateComplete();
}
});
return;
}
}
GLog.w(Messages.get(this, "no_vein"));
}
}
Aggregations