Search in sources :

Example 1 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION 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 FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class AtomicAi method getApproachCoordinate.

private Coordinates getApproachCoordinate(UnitAI ai) {
    Collection<Unit> units = getAnalyzer().getVisibleEnemies(ai);
    if (units.isEmpty())
        return null;
    FACING_DIRECTION facing = FacingMaster.getOptimalFacingTowardsUnits(getUnit().getCoordinates(), units, t -> getThreatAnalyzer().getThreat(ai, (Unit) t));
    if (facing == null)
        return null;
    Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(facing.getDirection());
    return Positioner.adjustCoordinate(ai.getUnit(), c, ai.getUnit().getFacing());
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 3 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class TurnSequenceConstructor method getTurnSequence.

public List<Action> getTurnSequence(FACING_SINGLE template, Unit source, Coordinates target) {
    FACING_DIRECTION original_facing = source.getFacing();
    FACING_DIRECTION facing = original_facing;
    boolean clockwise = true;
    int i = 0;
    List<Action> clockwise_list = new ArrayList<>();
    if (template == FacingMaster.getSingleFacing(FacingMaster.rotate180(facing), source.getCoordinates(), target)) {
        DC_UnitAction specAction = source.getAction("Turn About " + (RandomWizard.random() ? "anti" : "") + "clockwise");
        if (specAction != null) {
            clockwise_list.add(new Action(specAction));
            return clockwise_list;
        }
    }
    while (true) {
        if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
            break;
        }
        facing = FacingMaster.rotate(facing, clockwise);
        clockwise_list.add(getTurnAction(clockwise, source));
        i++;
        if (i > 2) {
            break;
        }
    }
    clockwise = false;
    i = 0;
    List<Action> anticlockwise_list = new ArrayList<>();
    facing = original_facing;
    while (true) {
        if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
            break;
        }
        facing = FacingMaster.rotate(facing, clockwise);
        anticlockwise_list.add(getTurnAction(clockwise, source));
        i++;
        if (i > 2) {
            break;
        }
    }
    return (anticlockwise_list.size() > clockwise_list.size()) ? clockwise_list : anticlockwise_list;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Action(eidolons.game.battlecraft.ai.elements.actions.Action) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ArrayList(java.util.ArrayList) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 4 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class DrawMaster method drawFacing.

private void drawFacing(Graphics g, Unit obj) {
    FACING_DIRECTION facing = obj.getFacing();
    Image img = ImageManager.getFacingImage(facing);
    int x = 0;
    int y = 0;
    int h = img.getHeight(null) * zoom / 100;
    int w = img.getWidth(null) * zoom / 100;
    int offset = obj.isSelected() ? 6 : 2;
    switch(facing) {
        case WEST:
            x = offset;
            y = getObjCompHeight() / 2 - h / 2;
            break;
        case NORTH:
            x = getObjCompWidth() / 2 - w / 2;
            y = +offset;
            break;
        case SOUTH:
            x = getObjCompWidth() / 2 - w / 2;
            y = getObjCompHeight() - img.getHeight(null) - offset;
            break;
        case EAST:
            x = getObjCompWidth() - w - offset;
            y = getObjCompHeight() / 2 - img.getHeight(null) / 2;
            break;
        case NONE:
            break;
    }
    if (!isSingleObj()) {
        x += topObjX;
        y += topObjY;
        switch(cellComp.getTopObj().getFacing()) {
            case SOUTH:
                // topObjY?
                y = Math.min(getCompHeight() - h, y + h);
                break;
            case NORTH:
                y = Math.max(0, y - h);
                break;
            case EAST:
                x = Math.min(getCompWidth() - w, x + w);
                break;
            case WEST:
                x = Math.max(0, x - w);
                break;
        }
    }
    drawImage(g, img, x, y);
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) BufferedImage(java.awt.image.BufferedImage)

Example 5 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class AnimMultiplicator method filterCoordinates.

private Collection<Coordinates> filterCoordinates(SPELL_ANIMS template, Set<Coordinates> coordinates) {
    if (template != null) {
        FACING_DIRECTION facing = getActive().getOwnerObj().getFacing();
        List<Coordinates> filtered = new ArrayList<>(coordinates);
        Coordinates farthest = CoordinatesMaster.getFarmostCoordinateInDirection(facing.getDirection(), new ArrayList<>(coordinates), null);
        switch(template) {
            // template.getNumberOfEmitters(getActive())
            case RAY:
                anim.setForcedDestinationForAll(farthest);
                return Arrays.asList(farthest);
            case BLAST:
                break;
            case WAVE:
            case SPRAY:
                {
                    boolean xOrY = !facing.isVertical();
                    filtered.removeIf(c -> farthest.getXorY(xOrY) != c.getXorY(xOrY));
                    while (filtered.size() < template.getNumberOfEmitters(getActive())) {
                        List<Coordinates> list = new ArrayList<>(coordinates);
                        list.removeAll(filtered);
                        list.removeIf(c -> farthest.getXorY(!xOrY) == c.getXorY(!xOrY));
                        Coordinates c = CoordinatesMaster.getFarmostCoordinateInDirection(facing.getDirection(), list, null);
                        if (c != null)
                            filtered.add(c);
                    }
                    if (ListMaster.isNotEmpty(filtered))
                        return filtered;
                    else
                        return coordinates;
                }
            case RING:
                break;
            case NOVA:
                break;
        }
    }
    return coordinates;
}
Also used : LogMaster(main.system.auxiliary.log.LogMaster) java.util(java.util) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) ListMaster(main.system.auxiliary.data.ListMaster) SpellAnim(eidolons.libgdx.anims.std.SpellAnim) SPELL_ANIMS(eidolons.libgdx.anims.std.SpellAnim.SPELL_ANIMS) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Action(com.badlogic.gdx.scenes.scene2d.Action) MoveByAction(com.badlogic.gdx.scenes.scene2d.actions.MoveByAction) EmitterPools(eidolons.libgdx.anims.particles.EmitterPools) GridMaster(eidolons.libgdx.bf.GridMaster) G_PARAMS(main.content.values.parameters.G_PARAMS) GridMaster.getCenteredPos(eidolons.libgdx.bf.GridMaster.getCenteredPos) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) EmitterActor(eidolons.libgdx.anims.particles.EmitterActor) Entity(main.entity.Entity) Ref(main.entity.Ref) Vector2(com.badlogic.gdx.math.Vector2) Coordinates(main.game.bf.Coordinates) CoordinatesMaster(eidolons.game.battlecraft.logic.battlefield.CoordinatesMaster) ZONE_ANIM_MODS(eidolons.libgdx.anims.std.SpellAnim.ZONE_ANIM_MODS) GeometryMaster(main.system.auxiliary.secondary.GeometryMaster) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates)

Aggregations

FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)31 Coordinates (main.game.bf.Coordinates)17 Unit (eidolons.entity.obj.unit.Unit)5 ArrayList (java.util.ArrayList)5 Ref (main.entity.Ref)5 ObjType (main.entity.type.ObjType)5 Obj (main.entity.obj.Obj)4 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)3 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)3 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)3 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)2 UnitLevelManager (eidolons.client.cc.logic.UnitLevelManager)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)2 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)2 Conditions (main.elements.conditions.Conditions)2 AutoTargeting (main.elements.targeting.AutoTargeting)2 MultiTargeting (main.elements.targeting.MultiTargeting)2 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 Targeting (main.elements.targeting.Targeting)2