Search in sources :

Example 26 with Char

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

the class WandOfTeleportation method onZap.

@Override
protected void onZap(int cell) {
    Char ch = Actor.findChar(cell);
    if (ch == curUser) {
        setKnown();
        ScrollOfTeleportation.teleportHero(curUser);
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1) {
            GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
        } else {
            ch.pos = pos;
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.visible[pos];
            GLog.i(curUser.name + " teleported " + ch.name + " to somewhere");
        }
    } else {
        GLog.i("nothing happened");
    }
}
Also used : Char(com.watabou.pixeldungeon.actors.Char)

Example 27 with Char

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

the class WandOfAvalanche method onZap.

@Override
protected void onZap(int cell) {
    Sample.INSTANCE.play(Assets.SND_ROCKS);
    int level = power();
    Ballistica.distance = Math.min(Ballistica.distance, 8 + level);
    int size = 1 + level / 3;
    PathFinder.buildDistanceMap(cell, BArray.not(Level.solid, null), size);
    int shake = 0;
    for (int i = 0; i < Level.LENGTH; i++) {
        int d = PathFinder.distance[i];
        if (d < Integer.MAX_VALUE) {
            Char ch = Actor.findChar(i);
            if (ch != null) {
                ch.sprite.flash();
                ch.damage(Random.Int(2, 6 + (size - d) * 2), this);
                if (ch.isAlive() && Random.Int(2 + d) == 0) {
                    Buff.prolong(ch, Paralysis.class, Random.IntRange(2, 6));
                }
            }
            if (ch != null && ch.isAlive()) {
                if (ch instanceof Mob) {
                    Dungeon.level.mobPress((Mob) ch);
                } else {
                    Dungeon.level.press(i, ch);
                }
            } else {
                Dungeon.level.press(i, null);
            }
            if (Dungeon.visible[i]) {
                CellEmitter.get(i).start(Speck.factory(Speck.ROCK), 0.07f, 3 + (size - d));
                if (Level.water[i]) {
                    GameScene.ripple(i);
                }
                if (shake < size - d) {
                    shake = size - d;
                }
            }
        }
        Camera.main.shake(3, 0.07f * (3 + shake));
    }
    if (!curUser.isAlive()) {
        Dungeon.fail(Utils.format(ResultDescriptions.WAND, name, Dungeon.depth));
        GLog.n("You killed yourself with your own Wand of Avalanche...");
    }
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Char(com.watabou.pixeldungeon.actors.Char)

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