use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfFlock method onZap.
@Override
protected void onZap(int cell) {
int level = power();
int n = level + 2;
if (Actor.findChar(cell) != null && Ballistica.distance > 2) {
cell = Ballistica.trace[Ballistica.distance - 2];
}
boolean[] passable = BArray.or(Level.passable, Level.avoid, null);
for (Actor actor : Actor.all()) {
if (actor instanceof Char) {
passable[((Char) actor).pos] = false;
}
}
PathFinder.buildDistanceMap(cell, passable, n);
int dist = 0;
if (Actor.findChar(cell) != null) {
PathFinder.distance[cell] = Integer.MAX_VALUE;
dist = 1;
}
float lifespan = level + 3;
sheepLabel: for (int i = 0; i < n; i++) {
do {
for (int j = 0; j < Level.LENGTH; j++) {
if (PathFinder.distance[j] == dist) {
Sheep sheep = new Sheep();
sheep.lifespan = lifespan;
sheep.pos = j;
GameScene.add(sheep);
Dungeon.level.mobPress(sheep);
CellEmitter.get(j).burst(Speck.factory(Speck.WOOL), 4);
PathFinder.distance[j] = Integer.MAX_VALUE;
continue sheepLabel;
}
}
dist++;
} while (dist < n);
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfLightning method fx.
@Override
protected void fx(int cell, Callback callback) {
nPoints = 0;
points[nPoints++] = Dungeon.hero.pos;
Char ch = Actor.findChar(cell);
if (ch != null) {
affected.clear();
int lvl = power();
hit(ch, Random.Int(5 + lvl / 2, 10 + lvl));
} else {
points[nPoints++] = cell;
CellEmitter.center(cell).burst(SparkParticle.FACTORY, 3);
}
curUser.sprite.parent.add(new Lightning(points, nPoints, callback));
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfLightning method hit.
private void hit(Char ch, int damage) {
if (damage < 1) {
return;
}
if (ch == Dungeon.hero) {
Camera.main.shake(2, 0.3f);
}
affected.add(ch);
ch.damage(Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);
ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
ch.sprite.flash();
points[nPoints++] = ch.pos;
HashSet<Char> ns = new HashSet<Char>();
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
if (n != null && !affected.contains(n)) {
ns.add(n);
}
}
if (ns.size() > 0) {
hit(Random.element(ns), Random.Int(damage / 2, damage));
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfMagicMissile method onZap.
@Override
protected void onZap(int cell) {
Char ch = Actor.findChar(cell);
if (ch != null) {
int level = power();
ch.damage(Random.Int(1, 6 + level * 2), this);
ch.sprite.burst(0xFF99CCFF, level / 2 + 2);
if (ch == curUser && !ch.isAlive()) {
Dungeon.fail(Utils.format(ResultDescriptions.WAND, name, Dungeon.depth));
GLog.n("You killed yourself with your own Wand of Magic Missile...");
}
}
}
use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.
the class WandOfReach method onZap.
@Override
protected void onZap(int cell) {
int reach = Math.min(Ballistica.distance, power() + 4);
boolean mapUpdated = false;
for (int i = 1; i < reach; i++) {
int c = Ballistica.trace[i];
int before = Dungeon.level.map[c];
Char ch = Actor.findChar(c);
if (ch != null) {
Actor.addDelayed(new Swap(curUser, ch), -1);
break;
}
Heap heap = Dungeon.level.heaps.get(c);
if (heap != null) {
switch(heap.type) {
case HEAP:
transport(heap);
break;
case CHEST:
case MIMIC:
case TOMB:
case SKELETON:
heap.open(curUser);
break;
default:
}
break;
}
Dungeon.level.press(c, null);
if (before == Terrain.OPEN_DOOR) {
Level.set(c, Terrain.DOOR);
GameScene.updateMap(c);
} else if (Level.water[c]) {
GameScene.ripple(c);
}
mapUpdated = mapUpdated || Dungeon.level.map[c] != before;
}
if (mapUpdated) {
Dungeon.observe();
}
}
Aggregations