Search in sources :

Example 1 with Pushing

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

the class Yog method defenseProc.

@Override
public int defenseProc(Char enemy, int damage) {
    ArrayList<Integer> spawnPoints = new ArrayList<>();
    for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
        int p = pos + PathFinder.NEIGHBOURS8[i];
        if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
            spawnPoints.add(p);
        }
    }
    if (spawnPoints.size() > 0) {
        Larva larva = new Larva();
        larva.pos = Random.element(spawnPoints);
        GameScene.add(larva);
        Actor.addDelayed(new Pushing(larva, pos, larva.pos), -1);
    }
    for (Mob mob : Dungeon.level.mobs) {
        if (mob instanceof BurningFist || mob instanceof RottingFist || mob instanceof Larva) {
            mob.aggro(enemy);
        }
    }
    return super.defenseProc(enemy, damage);
}
Also used : Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 2 with Pushing

use of com.shatteredpixel.shatteredpixeldungeon.effects.Pushing 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 3 with Pushing

use of com.shatteredpixel.shatteredpixeldungeon.effects.Pushing 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 4 with Pushing

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

the class Mimic method spawnAt.

public static Mimic spawnAt(int pos, List<Item> items) {
    if (Dungeon.level.pit[pos])
        return null;
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        ArrayList<Integer> candidates = new ArrayList<>();
        for (int n : PathFinder.NEIGHBOURS8) {
            int cell = pos + n;
            if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
                candidates.add(cell);
            }
        }
        if (candidates.size() > 0) {
            int newPos = Random.element(candidates);
            Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
            ch.pos = newPos;
            Dungeon.level.press(newPos, ch);
        } else {
            return null;
        }
    }
    Mimic m = new Mimic();
    m.items = new ArrayList<>(items);
    m.adjustStats(Dungeon.depth);
    m.pos = pos;
    m.state = m.HUNTING;
    GameScene.add(m, 1);
    m.sprite.turnTo(pos, Dungeon.hero.pos);
    if (Dungeon.level.heroFOV[m.pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
        Sample.INSTANCE.play(Assets.SND_MIMIC);
    }
    // generate an extra reward for killing the mimic
    Item reward = null;
    do {
        switch(Random.Int(5)) {
            case 0:
                reward = new Gold().random();
                break;
            case 1:
                reward = Generator.randomMissile();
                break;
            case 2:
                reward = Generator.randomArmor();
                break;
            case 3:
                reward = Generator.randomWeapon();
                break;
            case 4:
                reward = Generator.random(Generator.Category.RING);
                break;
        }
    } while (reward == null || Challenges.isItemBlocked(reward));
    m.items.add(reward);
    return m;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 5 with Pushing

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

the class Honeypot method shatter.

public Item shatter(Char owner, int pos) {
    if (Dungeon.level.heroFOV[pos]) {
        Sample.INSTANCE.play(Assets.SND_SHATTER);
        Splash.at(pos, 0xffd500, 5);
    }
    int newPos = pos;
    if (Actor.findChar(pos) != null) {
        ArrayList<Integer> candidates = new ArrayList<Integer>();
        boolean[] passable = Dungeon.level.passable;
        for (int n : PathFinder.NEIGHBOURS4) {
            int c = pos + n;
            if (passable[c] && Actor.findChar(c) == null) {
                candidates.add(c);
            }
        }
        newPos = candidates.size() > 0 ? Random.element(candidates) : -1;
    }
    if (newPos != -1) {
        Bee bee = new Bee();
        bee.spawn(Dungeon.depth);
        bee.setPotInfo(pos, owner);
        bee.HP = bee.HT;
        bee.pos = newPos;
        GameScene.add(bee);
        Actor.addDelayed(new Pushing(bee, pos, newPos), -1f);
        bee.sprite.alpha(0);
        bee.sprite.parent.add(new AlphaTweener(bee.sprite, 1, 0.15f));
        Sample.INSTANCE.play(Assets.SND_BEE);
        return new ShatteredPot().setBee(bee);
    } else {
        return this;
    }
}
Also used : Bee(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener)

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