Search in sources :

Example 26 with Mob

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

the class Dungeon method observe.

public static void observe(int dist) {
    if (level == null) {
        return;
    }
    level.updateFieldOfView(hero, level.heroFOV);
    int x = hero.pos % level.width();
    int y = hero.pos / level.width();
    // left, right, top, bottom
    int l = Math.max(0, x - dist);
    int r = Math.min(x + dist, level.width() - 1);
    int t = Math.max(0, y - dist);
    int b = Math.min(y + dist, level.height() - 1);
    int width = r - l + 1;
    int height = b - t + 1;
    int pos = l + t * level.width();
    for (int i = t; i <= b; i++) {
        BArray.or(level.visited, level.heroFOV, pos, width, level.visited);
        pos += level.width();
    }
    GameScene.updateFog(l, t, width, height);
    if (hero.buff(MindVision.class) != null) {
        for (Mob m : level.mobs.toArray(new Mob[0])) {
            BArray.or(level.visited, level.heroFOV, m.pos - 1 - level.width(), 3, level.visited);
            BArray.or(level.visited, level.heroFOV, m.pos, 3, level.visited);
            BArray.or(level.visited, level.heroFOV, m.pos - 1 + level.width(), 3, level.visited);
            // updates adjacent cells too
            GameScene.updateFog(m.pos, 2);
        }
    }
    if (hero.buff(Awareness.class) != null) {
        for (Heap h : level.heaps.values()) {
            BArray.or(level.visited, level.heroFOV, h.pos - 1 - level.width(), 3, level.visited);
            BArray.or(level.visited, level.heroFOV, h.pos - 1, 3, level.visited);
            BArray.or(level.visited, level.heroFOV, h.pos - 1 + level.width(), 3, level.visited);
            GameScene.updateFog(h.pos, 2);
        }
    }
    GameScene.afterObserve();
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Awareness(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness) MindVision(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 27 with Mob

use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob 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)

Example 28 with Mob

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

the class RegularLevel method createMobs.

@Override
protected void createMobs() {
    // on floor 1, 10 rats are created so the player can get level 2.
    int mobsToSpawn = Dungeon.depth == 1 ? 10 : nMobs();
    ArrayList<Room> stdRooms = new ArrayList<>();
    for (Room room : rooms) {
        if (room instanceof StandardRoom && room != roomEntrance) {
            for (int i = 0; i < ((StandardRoom) room).sizeCat.roomValue; i++) {
                stdRooms.add(room);
            }
        // pre-0.6.0 save compatibility
        } else if (room.legacyType.equals("STANDARD")) {
            stdRooms.add(room);
        }
    }
    Random.shuffle(stdRooms);
    Iterator<Room> stdRoomIter = stdRooms.iterator();
    while (mobsToSpawn > 0) {
        if (!stdRoomIter.hasNext())
            stdRoomIter = stdRooms.iterator();
        Room roomToSpawn = stdRoomIter.next();
        Mob mob = createMob();
        mob.pos = pointToCell(roomToSpawn.random());
        if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
            mobsToSpawn--;
            mobs.add(mob);
            // TODO: perhaps externalize this logic into a method. Do I want to make mobs more likely to clump deeper down?
            if (mobsToSpawn > 0 && Random.Int(4) == 0) {
                mob = createMob();
                mob.pos = pointToCell(roomToSpawn.random());
                if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
                    mobsToSpawn--;
                    mobs.add(mob);
                }
            }
        }
    }
    for (Mob m : mobs) {
        if (map[m.pos] == Terrain.HIGH_GRASS) {
            map[m.pos] = Terrain.GRASS;
            losBlocking[m.pos] = false;
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) ArrayList(java.util.ArrayList) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room) PitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom) ShopRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom) SpecialRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom) EntranceRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom) ExitRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom) SecretRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom) StandardRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom)

Example 29 with Mob

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

the class ScrollOfRage method doRead.

@Override
public void doRead() {
    for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
        mob.beckon(curUser.pos);
        if (Dungeon.level.heroFOV[mob.pos]) {
            Buff.prolong(mob, Amok.class, 5f);
        }
    }
    for (Heap heap : Dungeon.level.heaps.values()) {
        if (heap.type == Heap.Type.MIMIC) {
            Mimic m = Mimic.spawnAt(heap.pos, heap.items);
            if (m != null) {
                m.beckon(curUser.pos);
                heap.destroy();
            }
        }
    }
    GLog.w(Messages.get(this, "roar"));
    setKnown();
    curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
    Sample.INSTANCE.play(Assets.SND_CHALLENGE);
    Invisibility.dispel();
    readAnimation();
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 30 with Mob

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

the class DriedRose method holdGhostHero.

public static void holdGhostHero(Level level) {
    for (Mob mob : level.mobs.toArray(new Mob[0])) {
        if (mob instanceof DriedRose.GhostHero) {
            level.mobs.remove(mob);
            heldGhost = (GhostHero) mob;
            break;
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)

Aggregations

Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)49 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)13 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)11 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 ArrayList (java.util.ArrayList)6 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)4 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)3 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)3 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)3 CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)3 Point (com.watabou.utils.Point)3 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)2 Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)2 Burning (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)2 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)2 Terror (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror)2 King (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King)2 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)2 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)2