Search in sources :

Example 6 with Actor

use of com.shatteredpixel.shatteredpixeldungeon.actors.Actor in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Level method respawner.

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

        {
            // as if it were a buff.
            actPriority = BUFF_PRIO;
        }

        @Override
        protected boolean act() {
            int count = 0;
            for (Mob mob : mobs.toArray(new Mob[0])) {
                if (mob.alignment == Char.Alignment.ENEMY)
                    count++;
            }
            if (count < nMobs()) {
                Mob mob = createMob();
                mob.state = mob.WANDERING;
                mob.pos = randomRespawnCell();
                if (Dungeon.hero.isAlive() && mob.pos != -1 && distance(Dungeon.hero.pos, mob.pos) >= 4) {
                    GameScene.add(mob);
                    if (Statistics.amuletObtained) {
                        mob.beckon(Dungeon.hero.pos);
                    }
                }
            }
            if (Statistics.amuletObtained) {
                spend(TIME_TO_RESPAWN / 2f);
            } else if (Dungeon.level.feeling == Feeling.DARK) {
                spend(2 * TIME_TO_RESPAWN / 3f);
            } else {
                spend(TIME_TO_RESPAWN);
            }
            return true;
        }
    };
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Actor(com.shatteredpixel.shatteredpixeldungeon.actors.Actor) Point(com.watabou.utils.Point)

Aggregations

Actor (com.shatteredpixel.shatteredpixeldungeon.actors.Actor)6 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)3 Ballistica (com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica)3 Callback (com.watabou.utils.Callback)3 Light (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Light)1 Poison (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)1 PoisonDart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.PoisonDart)1 Point (com.watabou.utils.Point)1 IOException (java.io.IOException)1