Search in sources :

Example 16 with AlphaTweener

use of com.watabou.noosa.tweeners.AlphaTweener 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)

Example 17 with AlphaTweener

use of com.watabou.noosa.tweeners.AlphaTweener in project shattered-pixel-dungeon-gdx by 00-Evan.

the class BuffIndicator method layout.

@Override
protected void layout() {
    ArrayList<Buff> newBuffs = new ArrayList<>();
    for (Buff buff : ch.buffs()) {
        if (buff.icon() != NONE) {
            newBuffs.add(buff);
        }
    }
    // remove any icons no longer present
    for (Buff buff : buffIcons.keySet().toArray(new Buff[0])) {
        if (!newBuffs.contains(buff)) {
            Image icon = buffIcons.get(buff).icon;
            icon.origin.set(SIZE / 2);
            add(icon);
            add(new AlphaTweener(icon, 0, 0.6f) {

                @Override
                protected void updateValues(float progress) {
                    super.updateValues(progress);
                    image.scale.set(1 + 5 * progress);
                }

                @Override
                protected void onComplete() {
                    image.killAndErase();
                }
            });
            buffIcons.get(buff).destroy();
            remove(buffIcons.get(buff));
            buffIcons.remove(buff);
        }
    }
    // add new icons
    for (Buff buff : newBuffs) {
        if (!buffIcons.containsKey(buff)) {
            BuffIcon icon = new BuffIcon(buff);
            add(icon);
            buffIcons.put(buff, icon);
        }
    }
    // layout
    int pos = 0;
    for (BuffIcon icon : buffIcons.values()) {
        icon.updateIcon();
        icon.setRect(x + pos * (SIZE + 2), y, 9, 12);
        pos++;
    }
}
Also used : ArrayList(java.util.ArrayList) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff) WndInfoBuff(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoBuff) Image(com.watabou.noosa.Image)

Example 18 with AlphaTweener

use of com.watabou.noosa.tweeners.AlphaTweener in project pixel-dungeon-remix by NYRDS.

the class BuffIndicator method layout.

@Override
protected void layout() {
    clear();
    SparseArray<Image> newIcons = new SparseArray<>();
    for (Buff buff : ch.buffs()) {
        int icon = buff.icon();
        if (icon != NONE) {
            Image img = new Image(texture);
            img.frame(film.get(icon));
            img.x = x + members.size() * (SIZE + 2);
            img.y = y;
            add(img);
            newIcons.put(icon, img);
        }
    }
    for (Integer key : icons.keyArray()) {
        if (newIcons.get(key) == null) {
            Image icon = icons.get(key);
            icon.origin.set(SIZE / 2);
            add(icon);
            add(new AlphaTweener(icon, 0, 0.6f) {

                @Override
                protected void updateValues(float progress) {
                    super.updateValues(progress);
                    image.Scale().set(1 + 5 * progress);
                }
            });
        }
    }
    icons = newIcons;
}
Also used : SparseArray(com.watabou.utils.SparseArray) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener) Image(com.watabou.noosa.Image) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 19 with AlphaTweener

use of com.watabou.noosa.tweeners.AlphaTweener in project pixel-dungeon-remix by NYRDS.

the class ShadowLord method twistLevel.

private void twistLevel() {
    if (!isAlive()) {
        return;
    }
    Level level = Dungeon.level;
    if (!levelCreated) {
        Tools.makeEmptyLevel(level);
        Tools.buildShadowLordMaze(level, 6);
        levelCreated = true;
    }
    int cell = level.getRandomTerrainCell(Terrain.PEDESTAL);
    if (level.cellValid(cell)) {
        if (Actor.findChar(cell) == null) {
            Mob mob = Crystal.makeShadowLordCrystal();
            mob.setPos(cell);
            level.spawnMob(mob);
            mob.getSprite().alpha(0);
            mob.getSprite().getParent().add(new AlphaTweener(mob.getSprite(), 1, 0.4f));
            mob.getSprite().emitter().start(Speck.factory(Speck.LIGHT), 0.2f, 3);
            Sample.INSTANCE.play(Assets.SND_TELEPORT);
            int x, y;
            x = level.cellX(cell);
            y = level.cellY(cell);
            level.fillAreaWith(Darkness.class, x - 2, y - 2, 5, 5, 1);
        } else {
            damage(ht() / 9, this);
        }
    }
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Level(com.watabou.pixeldungeon.levels.Level) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener)

Example 20 with AlphaTweener

use of com.watabou.noosa.tweeners.AlphaTweener in project pixel-dungeon-remix by NYRDS.

the class WandOfBlink method appear.

public static void appear(Char ch, int pos) {
    ch.getSprite().interruptMotion();
    ch.move(pos);
    ch.getSprite().place(pos);
    if (ch.invisible == 0) {
        ch.getSprite().alpha(0);
        ch.getSprite().getParent().add(new AlphaTweener(ch.getSprite(), 1, 0.4f));
    }
    ch.getSprite().emitter().start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
}
Also used : AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener)

Aggregations

AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)20 Image (com.watabou.noosa.Image)6 ArrayList (java.util.ArrayList)3 Buff (com.watabou.pixeldungeon.actors.buffs.Buff)2 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)2 SparseArray (com.watabou.utils.SparseArray)2 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 Bee (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee)1 King (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)1 TorchHalo (com.shatteredpixel.shatteredpixeldungeon.effects.TorchHalo)1 WndInfoBuff (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoBuff)1 Bee (com.watabou.pixeldungeon.actors.mobs.npcs.Bee)1 Pushing (com.watabou.pixeldungeon.effects.Pushing)1 Level (com.watabou.pixeldungeon.levels.Level)1 Point (com.watabou.utils.Point)1