use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CursedWand method rareEffect.
private static void rareEffect(final Wand wand, final Hero user, final Ballistica bolt) {
switch(Random.Int(4)) {
// sheep transformation
case 0:
cursedFX(user, bolt, new Callback() {
public void call() {
Char ch = Actor.findChar(bolt.collisionPos);
if (ch != null && ch != user && !ch.properties().contains(Char.Property.BOSS) && !ch.properties().contains(Char.Property.MINIBOSS)) {
Sheep sheep = new Sheep();
sheep.lifespan = 10;
sheep.pos = ch.pos;
ch.destroy();
ch.sprite.killAndErase();
Dungeon.level.mobs.remove(ch);
TargetHealthIndicator.instance.target(null);
GameScene.add(sheep);
CellEmitter.get(sheep.pos).burst(Speck.factory(Speck.WOOL), 4);
} else {
GLog.i(Messages.get(CursedWand.class, "nothing"));
}
wand.wandUsed();
}
});
break;
// curses!
case 1:
CursingTrap.curse(user);
wand.wandUsed();
break;
// inter-level teleportation
case 2:
if (Dungeon.depth > 1 && !Dungeon.bossLevel()) {
// each depth has 1 more weight than the previous depth.
float[] depths = new float[Dungeon.depth - 1];
for (int i = 1; i < Dungeon.depth; i++) depths[i - 1] = i;
int depth = 1 + Random.chances(depths);
Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (buff != null)
buff.detach();
InterlevelScene.mode = InterlevelScene.Mode.RETURN;
InterlevelScene.returnDepth = depth;
InterlevelScene.returnPos = -1;
Game.switchScene(InterlevelScene.class);
} else {
ScrollOfTeleportation.teleportHero(user);
wand.wandUsed();
}
break;
// summon monsters
case 3:
new SummoningTrap().set(user.pos).activate();
wand.wandUsed();
break;
}
}
use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WandOfBlastWave method throwChar.
public static void throwChar(final Char ch, final Ballistica trajectory, int power) {
int dist = Math.min(trajectory.dist, power);
if (ch.properties().contains(Char.Property.BOSS))
dist /= 2;
if (dist == 0 || ch.properties().contains(Char.Property.IMMOVABLE))
return;
if (Actor.findChar(trajectory.path.get(dist)) != null) {
dist--;
}
final int newPos = trajectory.path.get(dist);
if (newPos == ch.pos)
return;
final int finalDist = dist;
final int initialpos = ch.pos;
Actor.addDelayed(new Pushing(ch, ch.pos, newPos, new Callback() {
public void call() {
if (initialpos != ch.pos) {
// something cased movement before pushing resolved, cancel to be safe.
ch.sprite.place(ch.pos);
return;
}
ch.pos = newPos;
if (ch.pos == trajectory.collisionPos) {
ch.damage(Random.NormalIntRange((finalDist + 1) / 2, finalDist), this);
Paralysis.prolong(ch, Paralysis.class, Random.NormalIntRange((finalDist + 1) / 2, finalDist));
}
Dungeon.level.press(ch.pos, ch, true);
if (ch == Dungeon.hero) {
Dungeon.observe();
}
}
}), -1);
}
use of com.watabou.utils.Callback in project pixel-dungeon-remix by NYRDS.
the class MobSpriteDef method selectKind.
@Override
public void selectKind(int kind) {
EventCollector.collectSessionData("selectKind", name);
this.kind = kind;
JSONObject json = defMap.get(name);
try {
texture(json.getString("texture"));
if (json.has("layers")) {
JSONArray layers = json.getJSONArray("layers");
for (int i = 0; i < layers.length(); ++i) {
JSONObject layer = layers.getJSONObject(i);
addLayer(layer.getString("id"), TextureCache.get(layer.get("texture")));
}
}
int width = json.getInt("width");
TextureFilm film = new TextureFilm(texture, width, json.getInt("height"));
bloodColor = 0xFFBB0000;
Object _bloodColor = json.opt("bloodColor");
if (_bloodColor instanceof Number) {
bloodColor = (int) _bloodColor;
}
if (_bloodColor instanceof String) {
bloodColor = Long.decode((String) _bloodColor).intValue();
}
levitating = json.optBoolean("levitating", false);
framesInRow = texture.width / width;
idle = readAnimation(json, "idle", film);
run = readAnimation(json, "run", film);
attack = readAnimation(json, "attack", film);
die = readAnimation(json, "die", film);
if (json.has("zap")) {
zap = readAnimation(json, "zap", film);
} else {
zap = attack.clone();
}
if (json.has("zapEffect")) {
zapEffect = json.getString("zapEffect");
zapCallback = new Callback() {
@Override
public void call() {
// ch.onZapComplete();
}
};
}
loadAdditionalData(json, film, kind);
} catch (Exception e) {
Game.toast(Utils.format("Something bad happens when loading %s", name), e);
throw new TrackedRuntimeException(Utils.format("Something bad happens when loading %s", name), e);
}
play(idle);
}
use of com.watabou.utils.Callback in project pixel-dungeon-remix by NYRDS.
the class PortalGate method playStartUpAnim.
protected void playStartUpAnim() {
animationRunning = true;
sprite.playAnim(8, false, new Callback() {
@Override
public void call() {
playActiveLoop();
activated = true;
animationRunning = false;
GLog.w(TXT_ACTIVATED);
}
}, image() + 0, image() + 1, image() + 2, image() + 3, image() + 4, image() + 5, image() + 6, image() + 7, image() + 8, image() + 9, image() + 10, image() + 11, image() + 12, image() + 13, image() + 14, image() + 15, image() + 16);
}
use of com.watabou.utils.Callback in project pixel-dungeon-remix by NYRDS.
the class Wand method wandEffect.
protected void wandEffect(final int cell) {
setKnown();
QuickSlot.target(curItem, Actor.findChar(cell));
if (curCharges() > 0) {
getCurUser().busy();
fx(cell, new Callback() {
@Override
public void call() {
onZap(cell);
wandUsed();
}
});
Invisibility.dispel(getCurUser());
} else {
getCurUser().spendAndNext(TIME_TO_ZAP);
GLog.w(TXT_FIZZLES);
levelKnown = true;
if (Random.Int(5) == 0) {
identify();
}
updateQuickslot();
}
}
Aggregations