use of com.shatteredpixel.shatteredpixeldungeon.effects.Pushing in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Swarm method defenseProc.
@Override
public int defenseProc(Char enemy, int damage) {
if (HP >= damage + 2) {
ArrayList<Integer> candidates = new ArrayList<>();
boolean[] solid = Dungeon.level.solid;
int[] neighbours = { pos + 1, pos - 1, pos + Dungeon.level.width(), pos - Dungeon.level.width() };
for (int n : neighbours) {
if (!solid[n] && Actor.findChar(n) == null) {
candidates.add(n);
}
}
if (candidates.size() > 0) {
Swarm clone = split();
clone.HP = (HP - damage) / 2;
clone.pos = Random.element(candidates);
clone.state = clone.HUNTING;
if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
Door.enter(clone.pos);
}
GameScene.add(clone, SPLIT_DELAY);
Actor.addDelayed(new Pushing(clone, pos, clone.pos), -1);
HP -= clone.HP;
}
}
return super.defenseProc(enemy, damage);
}
use of com.shatteredpixel.shatteredpixeldungeon.effects.Pushing 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.shatteredpixel.shatteredpixeldungeon.effects.Pushing 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);
}
Aggregations