use of com.watabou.pixeldungeon.actors.mobs.Mob in project pixel-dungeon by watabou.
the class QuickSlot method useTargeting.
private void useTargeting() {
targeting = lastTarget != null && lastTarget.isAlive() && Dungeon.visible[lastTarget.pos];
if (targeting) {
int pos = Ballistica.cast(Dungeon.hero.pos, lastTarget.pos, false, true);
if (pos != lastTarget.pos) {
lastTarget = null;
targeting = false;
}
}
if (!targeting) {
int n = Dungeon.hero.visibleEnemies();
for (int i = 0; i < n; i++) {
Mob enemy = Dungeon.hero.visibleEnemy(i);
int pos = Ballistica.cast(Dungeon.hero.pos, enemy.pos, false, true);
if (pos == enemy.pos) {
lastTarget = enemy;
targeting = true;
break;
}
}
}
if (targeting) {
if (Actor.all().contains(lastTarget)) {
lastTarget.sprite.parent.add(crossM);
crossM.point(DungeonTilemap.tileToWorld(lastTarget.pos));
crossB.visible = true;
} else {
lastTarget = null;
}
}
}
use of com.watabou.pixeldungeon.actors.mobs.Mob in project pixel-dungeon by watabou.
the class AttackIndicator method checkEnemies.
private void checkEnemies() {
int heroPos = Dungeon.hero.pos;
candidates.clear();
int v = Dungeon.hero.visibleEnemies();
for (int i = 0; i < v; i++) {
Mob mob = Dungeon.hero.visibleEnemy(i);
if (Level.adjacent(heroPos, mob.pos)) {
candidates.add(mob);
}
}
if (!candidates.contains(lastTarget)) {
if (candidates.isEmpty()) {
lastTarget = null;
} else {
lastTarget = Random.element(candidates);
updateImage();
flash();
}
} else {
if (!bg.visible) {
flash();
}
}
visible(lastTarget != null);
enable(bg.visible);
}
use of com.watabou.pixeldungeon.actors.mobs.Mob in project pixel-dungeon by watabou.
the class DangerIndicator method onClick.
@Override
protected void onClick() {
Mob target = Dungeon.hero.visibleEnemy(enemyIndex++);
HealthIndicator.instance.target(target == HealthIndicator.instance.target() ? null : target);
Camera.main.target = null;
Camera.main.focusOn(target.sprite);
}
use of com.watabou.pixeldungeon.actors.mobs.Mob in project pixel-dungeon by watabou.
the class MageArmor method doSpecial.
@Override
public void doSpecial() {
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Buff.affect(mob, Burning.class).reignite(mob);
Buff.prolong(mob, Roots.class, 3);
}
}
curUser.HP -= (curUser.HP / 3);
curUser.spend(Actor.TICK);
curUser.sprite.operate(curUser.pos);
curUser.busy();
curUser.sprite.centerEmitter().start(ElmoParticle.FACTORY, 0.15f, 4);
Sample.INSTANCE.play(Assets.SND_READ);
}
use of com.watabou.pixeldungeon.actors.mobs.Mob in project pixel-dungeon by watabou.
the class ScrollOfLullaby method doRead.
@Override
protected void doRead() {
curUser.sprite.centerEmitter().start(Speck.factory(Speck.NOTE), 0.3f, 5);
Sample.INSTANCE.play(Assets.SND_LULLABY);
Invisibility.dispel();
int count = 0;
Mob affected = null;
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
if (Level.fieldOfView[mob.pos]) {
Buff.affect(mob, Sleep.class);
if (mob.buff(Sleep.class) != null) {
affected = mob;
count++;
}
}
}
switch(count) {
case 0:
GLog.i("The scroll utters a soothing melody.");
break;
case 1:
GLog.i("The scroll utters a soothing melody and the " + affected.name + " falls asleep!");
break;
default:
GLog.i("The scroll utters a soothing melody and the monsters fall asleep!");
}
setKnown();
readAnimation();
}
Aggregations