use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfTeleportation method onZap.
@Override
protected void onZap(int cell) {
Char ch = Actor.findChar(cell);
if (ch == curUser) {
setKnown();
ScrollOfTeleportation.teleportHero(curUser);
} else if (ch != null) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1) {
GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
} else {
ch.pos = pos;
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.visible[pos];
GLog.i(curUser.name + " teleported " + ch.name + " to somewhere");
}
} else {
GLog.i("nothing happened");
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfAvalanche method onZap.
@Override
protected void onZap(int cell) {
Sample.INSTANCE.play(Assets.SND_ROCKS);
int level = power();
Ballistica.distance = Math.min(Ballistica.distance, 8 + level);
int size = 1 + level / 3;
PathFinder.buildDistanceMap(cell, BArray.not(Level.solid, null), size);
int shake = 0;
for (int i = 0; i < Level.LENGTH; i++) {
int d = PathFinder.distance[i];
if (d < Integer.MAX_VALUE) {
Char ch = Actor.findChar(i);
if (ch != null) {
ch.sprite.flash();
ch.damage(Random.Int(2, 6 + (size - d) * 2), this);
if (ch.isAlive() && Random.Int(2 + d) == 0) {
Buff.prolong(ch, Paralysis.class, Random.IntRange(2, 6));
}
}
if (ch != null && ch.isAlive()) {
if (ch instanceof Mob) {
Dungeon.level.mobPress((Mob) ch);
} else {
Dungeon.level.press(i, ch);
}
} else {
Dungeon.level.press(i, null);
}
if (Dungeon.visible[i]) {
CellEmitter.get(i).start(Speck.factory(Speck.ROCK), 0.07f, 3 + (size - d));
if (Level.water[i]) {
GameScene.ripple(i);
}
if (shake < size - d) {
shake = size - d;
}
}
}
Camera.main.shake(3, 0.07f * (3 + shake));
}
if (!curUser.isAlive()) {
Dungeon.fail(Utils.format(ResultDescriptions.WAND, name, Dungeon.depth));
GLog.n("You killed yourself with your own Wand of Avalanche...");
}
}
Aggregations