Search in sources :

Example 1 with Bee

use of com.watabou.pixeldungeon.actors.mobs.npcs.Bee in project pixel-dungeon by watabou.

the class Honeypot method shatter.

private void shatter(int pos) {
    Sample.INSTANCE.play(Assets.SND_SHATTER);
    if (Dungeon.visible[pos]) {
        Splash.at(pos, 0xffd500, 5);
    }
    int newPos = pos;
    if (Actor.findChar(pos) != null) {
        ArrayList<Integer> candidates = new ArrayList<Integer>();
        boolean[] passable = Level.passable;
        for (int n : Level.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.HP = bee.HT;
        bee.pos = newPos;
        GameScene.add(bee);
        Actor.addDelayed(new Pushing(bee, pos, newPos), -1);
        bee.sprite.alpha(0);
        bee.sprite.parent.add(new AlphaTweener(bee.sprite, 1, 0.15f));
        Sample.INSTANCE.play(Assets.SND_BEE);
    }
}
Also used : Bee(com.watabou.pixeldungeon.actors.mobs.npcs.Bee) Pushing(com.watabou.pixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener)

Aggregations

AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)1 Bee (com.watabou.pixeldungeon.actors.mobs.npcs.Bee)1 Pushing (com.watabou.pixeldungeon.effects.Pushing)1 ArrayList (java.util.ArrayList)1