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();
}
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;
}
};
}
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;
}
}
}
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();
}
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;
}
}
}
Aggregations