Search in sources :

Example 1 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class AtomicAi method checkAtomicActionTurn.

private boolean checkAtomicActionTurn(UnitAI ai) {
    // check that only enemy actions are needed
    boolean result = false;
    if (!ai.getType().isCaster()) {
        // FacingMaster.getOptimalFacingTowardsUnits()
        BattleFieldObject enemy = getAnalyzer().getClosestEnemy(ai.getUnit());
        // for (BattleFieldObject enemy : Analyzer.getVisibleEnemies(ai))
        FACING_DIRECTION facing = ai.getUnit().getFacing();
        FACING_SINGLE relative = FacingMaster.getSingleFacing(facing, ai.getUnit(), enemy);
        if (relative == FACING_SINGLE.BEHIND) {
            return true;
        } else if (relative == FACING_SINGLE.TO_THE_SIDE) {
            if (!ai.getUnit().checkPassive(STANDARD_PASSIVES.BROAD_REACH))
                result = true;
        } else
            result = false;
        // if we need to get to a cell that is not 'facing' the target?!
        if (!result)
            return false;
        if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(getUnit(), enemy))
            return false;
    }
    return result;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 2 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_BattleFieldGrid method resetComponents.

@Deprecated
private void resetComponents() {
    int offsetX = getOffsetX();
    int offsetY = getOffsetY();
    LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
    for (int i = 0; i < getDisplayedCellsX(); i++) {
        for (int j = 0; j < getDisplayedCellsY(); j++) {
            int x = i + getOffsetX();
            int y = j + getOffsetY();
            Coordinates c = new Coordinates(x, y);
            List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
            List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
            // visibility preCheck!
            CellComp comp = gridComp.getCells()[x][y];
            List<BattleFieldObject> list = new ArrayList<>();
            for (BattleFieldObject obj : objects) {
                if (VisionManager.checkVisible(obj)) {
                    list.add(obj);
                }
            }
            comp.setSizeFactor(gridComp.getZoom());
            comp.setOverlayingObjects(overlayingObjects);
            if (list.size() != 0) {
            // comp.setObjects(list);
            }
            comp.refresh();
        }
    }
    comp.refresh();
}
Also used : CellComp(eidolons.swing.components.obj.CellComp) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) DequeImpl(main.system.datatypes.DequeImpl)

Example 3 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_BattleFieldGrid method noObstacles.

private boolean noObstacles(int xy, int xy1, int xy2, Obj source, boolean x_y) {
    int max = xy2;
    int min = xy1;
    if (xy1 > xy2) {
        max = xy1;
        min = xy2;
    }
    for (int i = min + 1; i < max; i++) {
        Coordinates c = (x_y) ? new Coordinates(xy, i) : new Coordinates(i, xy);
        List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(getZ(), c, false, false, false);
        for (BattleFieldObject obj : objects) {
            if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
                return false;
            }
        }
    }
    return true;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates)

Example 4 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class DC_BattleFieldGrid method noObstaclesOnDiagonal.

@Override
public boolean noObstaclesOnDiagonal(Coordinates c1, Coordinates c2, Obj source) {
    boolean above = PositionMaster.isAbove(c1, c2);
    boolean left = PositionMaster.isToTheLeft(c1, c2);
    int X = c1.x;
    int Y = c1.y;
    while (X != c2.x || Y != c2.y) {
        if (above) {
            Y++;
        } else {
            Y--;
        }
        if (left) {
            X++;
        } else {
            X--;
        }
        if (X == c2.x || Y == c2.y) {
            break;
        }
        Coordinates c = new Coordinates(X, Y);
        List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(c, false);
        for (BattleFieldObject obj : objects) {
            if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
                return false;
            }
        }
    }
    return true;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates)

Example 5 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.

the class GuardRule method checkTargetChanged.

public static BattleFieldObject checkTargetChanged(DC_ActiveObj action) {
    BattleFieldObject target = (BattleFieldObject) action.getTargetObj();
    // attack.getAttackedUnit();
    List<Unit> guards = new ArrayList<>();
    Collection<Unit> units = target.getGame().getUnitsForCoordinates(target.getCoordinates());
    for (Unit unit : units) {
        if (unit.isAlliedTo(target.getOwner())) {
            if (unit.getMode() == STD_MODES.GUARDING || unit.checkStatus(STATUS.GUARDING)) {
                Ref ref = Ref.getCopy(action.getRef());
                ref.setTarget(target.getId());
                if (!SneakRule.checkSneak(ref))
                    guards.add(unit);
            }
        }
    }
    // TODO sort
    for (Unit guard : guards) {
        if (guard == target)
            continue;
        if (action.isAttackAny()) {
            if (action.isRanged()) {
                if (checkDefenderTakesMissile(action, guard))
                    return guard;
                continue;
            }
            Attack attack = EffectFinder.getAttackFromAction(action);
            if (checkDefenderTakesAttack(attack, guard))
                return guard;
        } else {
            if (checkDefenderTakesMissile(action, guard))
                return guard;
        }
    }
    // what kind of animation would there be?
    return null;
}
Also used : Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

BattleFieldObject (eidolons.entity.obj.BattleFieldObject)52 Unit (eidolons.entity.obj.unit.Unit)24 Coordinates (main.game.bf.Coordinates)22 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)12 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 Obj (main.entity.obj.Obj)9 DequeImpl (main.system.datatypes.DequeImpl)8 Event (main.game.logic.event.Event)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 DIRECTION (main.game.bf.Coordinates.DIRECTION)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Vector2 (com.badlogic.gdx.math.Vector2)4 Align (com.badlogic.gdx.utils.Align)4 Eidolons (eidolons.game.core.Eidolons)4 Gdx (com.badlogic.gdx.Gdx)3 Keys (com.badlogic.gdx.Input.Keys)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)3 Group (com.badlogic.gdx.scenes.scene2d.Group)3