Search in sources :

Example 1 with Pushing

use of com.watabou.pixeldungeon.effects.Pushing in project pixel-dungeon by watabou.

the class Bounce method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    int level = Math.max(0, armor.effectiveLevel());
    if (Level.adjacent(attacker.pos, defender.pos) && Random.Int(level + 5) >= 4) {
        for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
            int ofs = Level.NEIGHBOURS8[i];
            if (attacker.pos - defender.pos == ofs) {
                int newPos = attacker.pos + ofs;
                if ((Level.passable[newPos] || Level.avoid[newPos]) && Actor.findChar(newPos) == null) {
                    Actor.addDelayed(new Pushing(attacker, attacker.pos, newPos), -1);
                    attacker.pos = newPos;
                    // FIXME
                    if (attacker instanceof Mob) {
                        Dungeon.level.mobPress((Mob) attacker);
                    } else {
                        Dungeon.level.press(newPos, attacker);
                    }
                }
                break;
            }
        }
    }
    return damage;
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Pushing(com.watabou.pixeldungeon.effects.Pushing)

Example 2 with Pushing

use of com.watabou.pixeldungeon.effects.Pushing in project pixel-dungeon by watabou.

the class Mimic method spawnAt.

public static Mimic spawnAt(int pos, List<Item> items) {
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        ArrayList<Integer> candidates = new ArrayList<Integer>();
        for (int n : Level.NEIGHBOURS8) {
            int cell = pos + n;
            if ((Level.passable[cell] || 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;
            // FIXME
            if (ch instanceof Mob) {
                Dungeon.level.mobPress((Mob) ch);
            } else {
                Dungeon.level.press(newPos, ch);
            }
        } else {
            return null;
        }
    }
    Mimic m = new Mimic();
    m.items = new ArrayList<Item>(items);
    m.adjustStats(Dungeon.depth);
    m.HP = m.HT;
    m.pos = pos;
    m.state = m.HUNTING;
    GameScene.add(m, 1);
    m.sprite.turnTo(pos, Dungeon.hero.pos);
    if (Dungeon.visible[m.pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
        Sample.INSTANCE.play(Assets.SND_MIMIC);
    }
    return m;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Char(com.watabou.pixeldungeon.actors.Char) Pushing(com.watabou.pixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 3 with Pushing

use of com.watabou.pixeldungeon.effects.Pushing in project pixel-dungeon by watabou.

the class Swarm method defenseProc.

@Override
public int defenseProc(Char enemy, int damage) {
    if (HP >= damage + 2) {
        ArrayList<Integer> candidates = new ArrayList<Integer>();
        boolean[] passable = Level.passable;
        int[] neighbours = { pos + 1, pos - 1, pos + Level.WIDTH, pos - Level.WIDTH };
        for (int n : neighbours) {
            if (passable[n] && Actor.findChar(n) == null) {
                candidates.add(n);
            }
        }
        if (candidates.size() > 0) {
            Swarm clone = split();
            clone.HP = (HP - damage) / 2;
            clone.pos = Random.element(candidates);
            clone.state = clone.HUNTING;
            if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
                Door.enter(clone.pos);
            }
            GameScene.add(clone, SPLIT_DELAY);
            Actor.addDelayed(new Pushing(clone, pos, clone.pos), -1);
            HP -= clone.HP;
        }
    }
    return damage;
}
Also used : Pushing(com.watabou.pixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 4 with Pushing

use of com.watabou.pixeldungeon.effects.Pushing in project pixel-dungeon by watabou.

the class Yog method defenseProc.

@Override
public int defenseProc(Char enemy, int damage) {
    ArrayList<Integer> spawnPoints = new ArrayList<Integer>();
    for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
        int p = pos + Level.NEIGHBOURS8[i];
        if (Actor.findChar(p) == null && (Level.passable[p] || 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);
    }
    return super.defenseProc(enemy, damage);
}
Also used : Pushing(com.watabou.pixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 5 with Pushing

use of com.watabou.pixeldungeon.effects.Pushing 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

Pushing (com.watabou.pixeldungeon.effects.Pushing)6 ArrayList (java.util.ArrayList)4 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)1 Char (com.watabou.pixeldungeon.actors.Char)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Bee (com.watabou.pixeldungeon.actors.mobs.npcs.Bee)1 Item (com.watabou.pixeldungeon.items.Item)1