Search in sources :

Example 21 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfFlock method onZap.

@Override
protected void onZap(int cell) {
    int level = power();
    int n = level + 2;
    if (Actor.findChar(cell) != null && Ballistica.distance > 2) {
        cell = Ballistica.trace[Ballistica.distance - 2];
    }
    boolean[] passable = BArray.or(Level.passable, Level.avoid, null);
    for (Actor actor : Actor.all()) {
        if (actor instanceof Char) {
            passable[((Char) actor).pos] = false;
        }
    }
    PathFinder.buildDistanceMap(cell, passable, n);
    int dist = 0;
    if (Actor.findChar(cell) != null) {
        PathFinder.distance[cell] = Integer.MAX_VALUE;
        dist = 1;
    }
    float lifespan = level + 3;
    sheepLabel: for (int i = 0; i < n; i++) {
        do {
            for (int j = 0; j < Level.LENGTH; j++) {
                if (PathFinder.distance[j] == dist) {
                    Sheep sheep = new Sheep();
                    sheep.lifespan = lifespan;
                    sheep.pos = j;
                    GameScene.add(sheep);
                    Dungeon.level.mobPress(sheep);
                    CellEmitter.get(j).burst(Speck.factory(Speck.WOOL), 4);
                    PathFinder.distance[j] = Integer.MAX_VALUE;
                    continue sheepLabel;
                }
            }
            dist++;
        } while (dist < n);
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) Actor(com.watabou.pixeldungeon.actors.Actor)

Example 22 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfLightning method fx.

@Override
protected void fx(int cell, Callback callback) {
    nPoints = 0;
    points[nPoints++] = Dungeon.hero.pos;
    Char ch = Actor.findChar(cell);
    if (ch != null) {
        affected.clear();
        int lvl = power();
        hit(ch, Random.Int(5 + lvl / 2, 10 + lvl));
    } else {
        points[nPoints++] = cell;
        CellEmitter.center(cell).burst(SparkParticle.FACTORY, 3);
    }
    curUser.sprite.parent.add(new Lightning(points, nPoints, callback));
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) Lightning(com.watabou.pixeldungeon.effects.Lightning)

Example 23 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfLightning method hit.

private void hit(Char ch, int damage) {
    if (damage < 1) {
        return;
    }
    if (ch == Dungeon.hero) {
        Camera.main.shake(2, 0.3f);
    }
    affected.add(ch);
    ch.damage(Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);
    ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
    ch.sprite.flash();
    points[nPoints++] = ch.pos;
    HashSet<Char> ns = new HashSet<Char>();
    for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
        Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
        if (n != null && !affected.contains(n)) {
            ns.add(n);
        }
    }
    if (ns.size() > 0) {
        hit(Random.element(ns), Random.Int(damage / 2, damage));
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char) HashSet(java.util.HashSet)

Example 24 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfMagicMissile method onZap.

@Override
protected void onZap(int cell) {
    Char ch = Actor.findChar(cell);
    if (ch != null) {
        int level = power();
        ch.damage(Random.Int(1, 6 + level * 2), this);
        ch.sprite.burst(0xFF99CCFF, level / 2 + 2);
        if (ch == curUser && !ch.isAlive()) {
            Dungeon.fail(Utils.format(ResultDescriptions.WAND, name, Dungeon.depth));
            GLog.n("You killed yourself with your own Wand of Magic Missile...");
        }
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char)

Example 25 with Char

use of com.watabou.pixeldungeon.actors.Char in project pixel-dungeon by watabou.

the class WandOfReach method onZap.

@Override
protected void onZap(int cell) {
    int reach = Math.min(Ballistica.distance, power() + 4);
    boolean mapUpdated = false;
    for (int i = 1; i < reach; i++) {
        int c = Ballistica.trace[i];
        int before = Dungeon.level.map[c];
        Char ch = Actor.findChar(c);
        if (ch != null) {
            Actor.addDelayed(new Swap(curUser, ch), -1);
            break;
        }
        Heap heap = Dungeon.level.heaps.get(c);
        if (heap != null) {
            switch(heap.type) {
                case HEAP:
                    transport(heap);
                    break;
                case CHEST:
                case MIMIC:
                case TOMB:
                case SKELETON:
                    heap.open(curUser);
                    break;
                default:
            }
            break;
        }
        Dungeon.level.press(c, null);
        if (before == Terrain.OPEN_DOOR) {
            Level.set(c, Terrain.DOOR);
            GameScene.updateMap(c);
        } else if (Level.water[c]) {
            GameScene.ripple(c);
        }
        mapUpdated = mapUpdated || Dungeon.level.map[c] != before;
    }
    if (mapUpdated) {
        Dungeon.observe();
    }
}
Also used : Swap(com.watabou.pixeldungeon.effects.Swap) Char(com.watabou.pixeldungeon.actors.Char) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Char (com.watabou.pixeldungeon.actors.Char)27 Heap (com.watabou.pixeldungeon.items.Heap)4 Actor (com.watabou.pixeldungeon.actors.Actor)2 Burning (com.watabou.pixeldungeon.actors.buffs.Burning)2 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)1 SnipersMark (com.watabou.pixeldungeon.actors.buffs.SnipersMark)1 NPC (com.watabou.pixeldungeon.actors.mobs.npcs.NPC)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Lightning (com.watabou.pixeldungeon.effects.Lightning)1 Pushing (com.watabou.pixeldungeon.effects.Pushing)1 Swap (com.watabou.pixeldungeon.effects.Swap)1 Item (com.watabou.pixeldungeon.items.Item)1 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)1 MissileSprite (com.watabou.pixeldungeon.sprites.MissileSprite)1 Callback (com.watabou.utils.Callback)1