Search in sources :

Example 6 with Pushing

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);
}
Also used : Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 7 with Pushing

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();
        }
    }));
}
Also used : Callback(com.watabou.utils.Callback) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) Chains(com.shatteredpixel.shatteredpixeldungeon.effects.Chains)

Example 8 with Pushing

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);
}
Also used : Callback(com.watabou.utils.Callback) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)

Aggregations

Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)8 Callback (com.watabou.utils.Callback)4 ArrayList (java.util.ArrayList)4 Chains (com.shatteredpixel.shatteredpixeldungeon.effects.Chains)3 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Bee (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee)1 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)1 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)1