Search in sources :

Example 1 with Actor

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

the class Dungeon method switchLevel.

@SuppressWarnings("deprecation")
public static void switchLevel(final Level level, int pos) {
    nightMode = new Date().getHours() < 7;
    Dungeon.level = level;
    Actor.init();
    Actor respawner = level.respawner();
    if (respawner != null) {
        Actor.add(level.respawner());
    }
    hero.pos = pos != -1 ? pos : level.exit;
    Light light = hero.buff(Light.class);
    hero.viewDistance = light == null ? level.viewDistance : Math.max(Light.DISTANCE, level.viewDistance);
    observe();
}
Also used : Light(com.watabou.pixeldungeon.actors.buffs.Light) Actor(com.watabou.pixeldungeon.actors.Actor) Date(java.util.Date)

Example 2 with Actor

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

the class Level method respawner.

public Actor respawner() {
    return new Actor() {

        @Override
        protected boolean act() {
            if (mobs.size() < nMobs()) {
                Mob mob = Bestiary.mutable(Dungeon.depth);
                mob.state = mob.WANDERING;
                mob.pos = randomRespawnCell();
                if (Dungeon.hero.isAlive() && mob.pos != -1) {
                    GameScene.add(mob);
                    if (Statistics.amuletObtained) {
                        mob.beckon(Dungeon.hero.pos);
                    }
                }
            }
            spend(Dungeon.nightMode || Statistics.amuletObtained ? TIME_TO_RESPAWN / 2 : TIME_TO_RESPAWN);
            return true;
        }
    };
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Actor(com.watabou.pixeldungeon.actors.Actor)

Example 3 with Actor

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

the class King method summon.

private void summon() {
    nextPedestal = !nextPedestal;
    sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2);
    Sample.INSTANCE.play(Assets.SND_CHALLENGE);
    boolean[] passable = Level.passable.clone();
    for (Actor actor : Actor.all()) {
        if (actor instanceof Char) {
            passable[((Char) actor).pos] = false;
        }
    }
    int undeadsToSummon = maxArmySize() - Undead.count;
    PathFinder.buildDistanceMap(pos, passable, undeadsToSummon);
    PathFinder.distance[pos] = Integer.MAX_VALUE;
    int dist = 1;
    undeadLabel: for (int i = 0; i < undeadsToSummon; i++) {
        do {
            for (int j = 0; j < Level.LENGTH; j++) {
                if (PathFinder.distance[j] == dist) {
                    Undead undead = new Undead();
                    undead.pos = j;
                    GameScene.add(undead);
                    WandOfBlink.appear(undead, j);
                    new Flare(3, 32).color(0x000000, false).show(undead.sprite, 2f);
                    PathFinder.distance[j] = Integer.MAX_VALUE;
                    continue undeadLabel;
                }
            }
            dist++;
        } while (dist < undeadsToSummon);
    }
    yell("Arise, slaves!");
}
Also used : Flare(com.watabou.pixeldungeon.effects.Flare) Char(com.watabou.pixeldungeon.actors.Char) Actor(com.watabou.pixeldungeon.actors.Actor)

Example 4 with Actor

use of com.watabou.pixeldungeon.actors.Actor 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)

Aggregations

Actor (com.watabou.pixeldungeon.actors.Actor)4 Char (com.watabou.pixeldungeon.actors.Char)2 Light (com.watabou.pixeldungeon.actors.buffs.Light)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 Date (java.util.Date)1