use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class AlarmTrap method activate.
@Override
public void activate() {
for (Mob mob : Dungeon.level.mobs) {
mob.beckon(pos);
}
if (Dungeon.level.heroFOV[pos]) {
GLog.w(Messages.get(this, "alarm"));
CellEmitter.center(pos).start(Speck.factory(Speck.SCREAM), 0.3f, 3);
}
Sample.INSTANCE.play(Assets.SND_ALERT);
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WarpingTrap method activate.
@Override
public void activate() {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
Sample.INSTANCE.play(Assets.SND_TELEPORT);
Char ch = Actor.findChar(pos);
if (ch instanceof Hero) {
ScrollOfTeleportation.teleportHero((Hero) ch);
BArray.setFalse(Dungeon.level.visited);
BArray.setFalse(Dungeon.level.mapped);
GameScene.updateFog();
Dungeon.observe();
} else if (ch != null) {
int count = 10;
int pos;
do {
pos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (pos == -1);
if (pos == -1 || Dungeon.bossLevel()) {
GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
} else {
ch.pos = pos;
if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
((Mob) ch).state = ((Mob) ch).WANDERING;
}
ch.sprite.place(ch.pos);
ch.sprite.visible = Dungeon.level.heroFOV[pos];
}
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int cell = Dungeon.level.randomRespawnCell();
Item item = heap.pickUp();
if (cell != -1) {
Dungeon.level.drop(item, cell);
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Actor method init.
public static void init() {
add(Dungeon.hero);
for (Mob mob : Dungeon.level.mobs) {
add(mob);
}
for (Blob blob : Dungeon.level.blobs.values()) {
add(blob);
}
current = null;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method handle.
public boolean handle(int cell) {
if (cell == -1) {
return false;
}
Char ch;
Heap heap;
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Alchemy(cell);
} else if (fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) {
if (ch instanceof NPC) {
curAction = new HeroAction.Interact((NPC) ch);
} else {
curAction = new HeroAction.Attack(ch);
}
} else if ((heap = Dungeon.level.heaps.get(cell)) != null && // moving to an item doesn't auto-pickup when enemies are near...
(visibleEnemies.size() == 0 || cell == pos || // ...but only for standard heaps, chests and similar open as normal.
(heap.type != Type.HEAP && heap.type != Type.FOR_SALE))) {
switch(heap.type) {
case HEAP:
curAction = new HeroAction.PickUp(cell);
break;
case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell);
break;
default:
curAction = new HeroAction.OpenChest(cell);
}
} else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) {
curAction = new HeroAction.Unlock(cell);
} else if (cell == Dungeon.level.exit && Dungeon.depth < 26) {
curAction = new HeroAction.Descend(cell);
} else if (cell == Dungeon.level.entrance) {
curAction = new HeroAction.Ascend(cell);
} else {
curAction = new HeroAction.Move(cell);
lastAction = null;
}
if (ready)
return act();
else
return false;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method press.
// a 'soft' press ignores hidden traps
// a 'hard' press triggers all things
// generally a 'hard' press should be forced is something is moving forcefully (e.g. thrown)
public void press(int cell, Char ch, boolean hard) {
if (ch != null && pit[cell] && !ch.flying) {
if (ch == Dungeon.hero) {
Chasm.heroFall(cell);
} else if (ch instanceof Mob) {
Chasm.mobFall((Mob) ch);
}
return;
}
Trap trap = null;
switch(map[cell]) {
case Terrain.SECRET_TRAP:
if (hard) {
trap = traps.get(cell);
GLog.i(Messages.get(Level.class, "hidden_trap", trap.name));
}
break;
case Terrain.TRAP:
trap = traps.get(cell);
break;
case Terrain.HIGH_GRASS:
HighGrass.trample(this, cell, ch);
break;
case Terrain.WELL:
WellWater.affectCell(cell);
break;
case Terrain.DOOR:
Door.enter(cell);
break;
}
if (trap != null) {
TimekeepersHourglass.timeFreeze timeFreeze = ch != null ? ch.buff(TimekeepersHourglass.timeFreeze.class) : null;
if (timeFreeze == null) {
if (ch == Dungeon.hero) {
Dungeon.hero.interrupt();
}
trap.trigger();
} else {
Sample.INSTANCE.play(Assets.SND_TRAP);
discover(cell);
timeFreeze.setDelayedPress(cell);
}
}
Plant plant = plants.get(cell);
if (plant != null) {
plant.trigger();
}
}
Aggregations