Search in sources :

Example 26 with Callback

use of com.watabou.utils.Callback in project pixel-dungeon by watabou.

the class HeroSprite method read.

public void read() {
    animCallback = new Callback() {

        @Override
        public void call() {
            idle();
            ch.onOperateComplete();
        }
    };
    play(read);
}
Also used : Callback(com.watabou.utils.Callback)

Example 27 with Callback

use of com.watabou.utils.Callback in project pixel-dungeon by watabou.

the class WarlockSprite method zap.

public void zap(int cell) {
    turnTo(ch.pos, cell);
    play(zap);
    MagicMissile.shadow(parent, ch.pos, cell, new Callback() {

        @Override
        public void call() {
            ((Warlock) ch).onZapComplete();
        }
    });
    Sample.INSTANCE.play(Assets.SND_ZAP);
}
Also used : Callback(com.watabou.utils.Callback)

Example 28 with Callback

use of com.watabou.utils.Callback 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 29 with Callback

use of com.watabou.utils.Callback 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 30 with Callback

use of com.watabou.utils.Callback in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Pickaxe method execute.

@Override
public void execute(final Hero hero, String action) {
    super.execute(hero, action);
    if (action.equals(AC_MINE)) {
        if (Dungeon.depth < 11 || Dungeon.depth > 15) {
            GLog.w(Messages.get(this, "no_vein"));
            return;
        }
        for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
            final int pos = hero.pos + PathFinder.NEIGHBOURS8[i];
            if (Dungeon.level.map[pos] == Terrain.WALL_DECO) {
                hero.spend(TIME_TO_MINE);
                hero.busy();
                hero.sprite.attack(pos, new Callback() {

                    @Override
                    public void call() {
                        CellEmitter.center(pos).burst(Speck.factory(Speck.STAR), 7);
                        Sample.INSTANCE.play(Assets.SND_EVOKE);
                        Level.set(pos, Terrain.WALL);
                        GameScene.updateMap(pos);
                        DarkGold gold = new DarkGold();
                        if (gold.doPickUp(Dungeon.hero)) {
                            GLog.i(Messages.get(Dungeon.hero, "you_now_have", gold.name()));
                        } else {
                            Dungeon.level.drop(gold, hero.pos).sprite.drop();
                        }
                        hero.onOperateComplete();
                    }
                });
                return;
            }
        }
        GLog.w(Messages.get(this, "no_vein"));
    }
}
Also used : Callback(com.watabou.utils.Callback)

Aggregations

Callback (com.watabou.utils.Callback)43 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)8 Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)4 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)4 Char (com.watabou.pixeldungeon.actors.Char)4 MissileSprite (com.watabou.pixeldungeon.sprites.MissileSprite)4 Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)3 Chains (com.shatteredpixel.shatteredpixeldungeon.effects.Chains)3 Shuriken (com.watabou.pixeldungeon.items.weapon.missiles.Shuriken)3 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)2 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)2 Shuriken (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Shuriken)2 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)2 MissileSprite (com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite)2 BitmapText (com.watabou.noosa.BitmapText)2 Hunger (com.watabou.pixeldungeon.actors.buffs.Hunger)2 SnipersMark (com.watabou.pixeldungeon.actors.buffs.SnipersMark)2 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)2 Item (com.watabou.pixeldungeon.items.Item)2 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)2