use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method checkVisibleMobs.
public void checkVisibleMobs() {
ArrayList<Mob> visible = new ArrayList<>();
boolean newMob = false;
Mob target = null;
for (Mob m : Dungeon.level.mobs.toArray(new Mob[0])) {
if (fieldOfView[m.pos] && m.alignment == Alignment.ENEMY) {
visible.add(m);
if (!visibleEnemies.contains(m)) {
newMob = true;
}
if (!mindVisionEnemies.contains(m) && QuickSlotButton.autoAim(m) != -1) {
if (target == null) {
target = m;
} else if (distance(target) > distance(m)) {
target = m;
}
}
}
}
if (target != null && (QuickSlotButton.lastTarget == null || !QuickSlotButton.lastTarget.isAlive() || !fieldOfView[QuickSlotButton.lastTarget.pos])) {
QuickSlotButton.target(target);
}
if (newMob) {
interrupt();
resting = false;
}
visibleEnemies = visible;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method canAttack.
public boolean canAttack(Char enemy) {
if (enemy == null || pos == enemy.pos)
return false;
// can always attack adjacent enemies
if (Dungeon.level.adjacent(pos, enemy.pos))
return true;
KindOfWeapon wep = Dungeon.hero.belongings.weapon;
if (wep != null && Dungeon.level.distance(pos, enemy.pos) <= wep.reachFactor(this)) {
boolean[] passable = BArray.not(Dungeon.level.solid, null);
for (Mob m : Dungeon.level.mobs) passable[m.pos] = false;
PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this));
return PathFinder.distance[pos] <= wep.reachFactor(this);
} else {
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class AttackIndicator method checkEnemies.
private synchronized void checkEnemies() {
candidates.clear();
int v = Dungeon.hero.visibleEnemies();
for (int i = 0; i < v; i++) {
Mob mob = Dungeon.hero.visibleEnemy(i);
if (Dungeon.hero.canAttack(mob)) {
candidates.add(mob);
}
}
if (!candidates.contains(lastTarget)) {
if (candidates.isEmpty()) {
lastTarget = null;
} else {
active = true;
lastTarget = Random.element(candidates);
updateImage();
flash();
}
} else {
if (!bg.visible) {
active = true;
flash();
}
}
visible(lastTarget != null);
enable(bg.visible);
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob in project shattered-pixel-dungeon-gdx by 00-Evan.
the class DangerIndicator method onClick.
@Override
protected void onClick() {
if (Dungeon.hero.visibleEnemies() > 0) {
Mob target = Dungeon.hero.visibleEnemy(enemyIndex++);
TargetHealthIndicator.instance.target(target == TargetHealthIndicator.instance.target() ? null : target);
if (Dungeon.hero.curAction == null) {
Camera.main.target = null;
Camera.main.focusOn(target.sprite);
}
}
}
Aggregations