Search in sources :

Example 46 with Mob

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;
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) ArrayList(java.util.ArrayList)

Example 47 with Mob

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;
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)

Example 48 with Mob

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);
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)

Example 49 with Mob

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