Search in sources :

Example 1 with Chains

use of com.shatteredpixel.shatteredpixeldungeon.effects.Chains in project shattered-pixel-dungeon-gdx by 00-Evan.

the class EtherealChains method chainEnemy.

// pulls an enemy to a position along the chain's path, as close to the hero as possible
private void chainEnemy(Ballistica chain, final Hero hero, final Char enemy) {
    if (enemy.properties().contains(Char.Property.IMMOVABLE)) {
        GLog.w(Messages.get(this, "cant_pull"));
        return;
    }
    int bestPos = -1;
    for (int i : chain.subPath(1, chain.dist)) {
        // prefer to the earliest point on the path
        if (!Dungeon.level.solid[i] && Actor.findChar(i) == null) {
            bestPos = i;
            break;
        }
    }
    if (bestPos == -1) {
        GLog.i(Messages.get(this, "does_nothing"));
        return;
    }
    final int pulledPos = bestPos;
    int chargeUse = Dungeon.level.distance(enemy.pos, pulledPos);
    if (chargeUse > charge) {
        GLog.w(Messages.get(this, "no_charge"));
        return;
    } else {
        charge -= chargeUse;
        updateQuickslot();
    }
    hero.busy();
    hero.sprite.parent.add(new Chains(hero.sprite.center(), enemy.sprite.center(), new Callback() {

        public void call() {
            Actor.add(new Pushing(enemy, enemy.pos, pulledPos, new Callback() {

                public void call() {
                    Dungeon.level.press(pulledPos, enemy, true);
                }
            }));
            enemy.pos = pulledPos;
            Dungeon.observe();
            GameScene.updateFog();
            hero.spendAndNext(1f);
        }
    }));
}
Also used : Callback(com.watabou.utils.Callback) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) Chains(com.shatteredpixel.shatteredpixeldungeon.effects.Chains)

Example 2 with Chains

use of com.shatteredpixel.shatteredpixeldungeon.effects.Chains in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Guard method chain.

private boolean chain(int target) {
    if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))
        return false;
    Ballistica chain = new Ballistica(pos, target, Ballistica.PROJECTILE);
    if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || Dungeon.level.pit[chain.path.get(1)])
        return false;
    else {
        int newPos = -1;
        for (int i : chain.subPath(1, chain.dist)) {
            if (!Dungeon.level.solid[i] && Actor.findChar(i) == null) {
                newPos = i;
                break;
            }
        }
        if (newPos == -1) {
            return false;
        } else {
            final int newPosFinal = newPos;
            this.target = newPos;
            yell(Messages.get(this, "scorpion"));
            sprite.parent.add(new Chains(sprite.center(), enemy.sprite.center(), new Callback() {

                public void call() {
                    Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {

                        public void call() {
                            enemy.pos = newPosFinal;
                            Dungeon.level.press(newPosFinal, enemy, true);
                            Cripple.prolong(enemy, Cripple.class, 4f);
                            if (enemy == Dungeon.hero) {
                                Dungeon.hero.interrupt();
                                Dungeon.observe();
                                GameScene.updateFog();
                            }
                        }
                    }), -1);
                    next();
                }
            }));
        }
    }
    chainsUsed = true;
    return true;
}
Also used : Callback(com.watabou.utils.Callback) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Chains(com.shatteredpixel.shatteredpixeldungeon.effects.Chains)

Example 3 with Chains

use of com.shatteredpixel.shatteredpixeldungeon.effects.Chains 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)

Aggregations

Chains (com.shatteredpixel.shatteredpixeldungeon.effects.Chains)3 Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)3 Callback (com.watabou.utils.Callback)3 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)1