Search in sources :

Example 26 with DIRECTION

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

the class ForceRule method applyPush.

// TODO into PushEffect! With std knockdown on "landing" or damage!
public static void applyPush(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
    DIRECTION d = DirectionMaster.getRelativeDirection(source, target);
    if (attack.isSpell()) {
        d = DirectionMaster.getRelativeDirection(attack.getRef().getTargetObj(), target);
    // cell
    }
    int distance = getPushDistance(MathMaster.applyModIfNotZero(force, attack.getFinalModParam(PARAMS.FORCE_PUSH_MOD)), target);
    if (distance == 0) {
        if (isTestMode()) {
            distance = 1;
        } else {
            return;
        }
    }
    if (d.isDiagonal()) {
        distance = (int) Math.round(Math.sqrt(distance));
        if (distance == 0) {
            d = d.rotate90(RandomWizard.random());
            distance = 1;
        }
    }
    // int weight = target.getIntParam(PARAMS.TOTAL_WEIGHT);
    // if (distance == 0)
    // distance = RandomWizard.chance(force * 100 / weight) ? 1 : 0; // TODO
    int x_displacement = BooleanMaster.isTrue(d.growX) ? distance : -distance;
    int y_displacement = BooleanMaster.isTrue(d.growY) ? distance : -distance;
    if (!d.isDiagonal()) {
        if (d.isVertical()) {
            x_displacement = 0;
        } else {
            y_displacement = 0;
        }
    }
    Ref ref = attack.getRef().getCopy();
    ref.setTarget(target.getId());
    new MoveEffect("target", new Formula("" + x_displacement), new Formula("" + y_displacement)).apply(ref);
// roll dexterity against Fall Down
// TODO knock vs push - which is 'critical'?
// maybe just apply a modifier, then calculate if push/knock?
// sometimes it'll be better to be 'weak', eh?
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DIRECTION(main.game.bf.Coordinates.DIRECTION) MoveEffect(eidolons.ability.effects.oneshot.move.MoveEffect)

Example 27 with DIRECTION

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

the class PathChoiceMaster method getDefaultCoordinateTargets.

private List<Coordinates> getDefaultCoordinateTargets(ActionPath path, Coordinates c_coordinate) {
    List<Coordinates> list = new ArrayList<>();
    for (DIRECTION d : DIRECTION.values) {
        if (d.isDiagonal()) {
            continue;
        }
        Coordinates c = c_coordinate.getAdjacentCoordinate(d);
        if (c == pathBuilder.getPreviousCoordinate() || c == null) {
            continue;
        }
        if (path.hasCoordinate(c)) {
            continue;
        }
        if (!pathBuilder.checkEmpty(c)) {
            continue;
        }
        // if (FacingManager.getSingleFacing(c_facing, c_coordinate, c) !=
        // FACING_SINGLE.BEHIND)
        list.add(c);
    }
    return list;
}
Also used : Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION)

Example 28 with DIRECTION

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

the class DC_ObjInitializer method initDirectionMap.

public static void initDirectionMap(int z, Map<String, DIRECTION> directionMap) {
    for (String data : directionMap.keySet()) {
        Coordinates c = getCoordinatesFromObjString(data);
        DIRECTION d = directionMap.get(data);
        for (BattleFieldObject obj : DC_Game.game.getObjectsOnCoordinate(z, c, null, false, false)) {
            String name = getNameFromObjString(data);
            if (name.contains(MULTI_DIRECTION_SUFFIX)) {
                name = name.split(MULTI_DIRECTION_SUFFIX)[0];
            }
            if (!name.equals(obj.getName())) {
                continue;
            }
            Map<BattleFieldObject, DIRECTION> map = obj.getGame().getDirectionMap().get(c);
            if (map == null) {
                map = new HashMap<>();
                obj.getGame().getDirectionMap().put(c, map);
            }
            obj.setDirection(d);
            map.put(obj, d);
        }
    }
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Example 29 with DIRECTION

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

the class MiniGrid method getOverlayingMigString.

private String getOverlayingMigString(Unit obj, boolean multi) {
    Coordinates c = obj.getCoordinates();
    int width = getOverlayingObjWidth();
    int height = overlayingObjHeight;
    if (multi) {
        width = getOverlayingObjWidth() * 3 / 4;
        height = getOverlayingObjWidth() * 3 / 4;
    }
    int xOffset = (getCellWidth() - width) / 2;
    int yOffset = (cellHeight - height) / 2;
    DIRECTION d = obj.getDirection();
    if (d != null) {
        if (d.growX != null) {
            xOffset = (d.growX) ? getCellWidth() - width : 0;
        }
        if (d.growY != null) {
            yOffset = (d.growY) ? cellHeight - overlayingObjHeight : 0;
        }
    }
    int w = (offsetX + c.x) * getCellWidth();
    w += xOffset;
    int h = (offsetY + c.y) * cellHeight;
    h += yOffset;
    return "pos " + (defaultOffsetX + w) + " " + (defaultOffsetY + h);
}
Also used : Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Example 30 with DIRECTION

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

the class DebugMaster method editAi.

public void editAi(Unit unit) {
    UnitAI ai = unit.getUnitAI();
    GroupAI group = ai.getGroup();
    DialogMaster.confirm("What to do with " + group);
    String TRUE = "Info";
    String FALSE = "Set Behavior";
    String NULL = "Set Parameter";
    String string = "What to do with " + group + "?";
    Boolean result = DialogMaster.askAndWait(string, TRUE, FALSE, NULL);
    LogMaster.log(1, " ");
    DIRECTION info = group.getWanderDirection();
    // TODO GLOBAL AI LOG LEVEL
    if (result == null) {
        AI_PARAM param = new EnumMaster<AI_PARAM>().retrieveEnumConst(AI_PARAM.class, ListChooser.chooseEnum(AI_PARAM.class));
        if (param != null) {
            switch(param) {
                case LOG_LEVEL:
                    ai.setLogLevel(DialogMaster.inputInt(ai.getLogLevel()));
                    break;
            }
        }
    }
    /*
         * display on BF: >> Direction >> Target coordinate for each unit or
		 * patrol >> Maybe even path... >>
		 *
		 *
		 */
    group.getPatrol();
}
Also used : GroupAI(eidolons.game.battlecraft.ai.GroupAI) UnitAI(eidolons.game.battlecraft.ai.UnitAI) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Aggregations

DIRECTION (main.game.bf.Coordinates.DIRECTION)32 Coordinates (main.game.bf.Coordinates)18 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)11 DC_Obj (eidolons.entity.obj.DC_Obj)9 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 Unit (eidolons.entity.obj.unit.Unit)6 ArrayList (java.util.ArrayList)5 Obj (main.entity.obj.Obj)5 DC_Cell (eidolons.entity.obj.DC_Cell)2 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)2 Color (com.badlogic.gdx.graphics.Color)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 MoveEffect (eidolons.ability.effects.oneshot.move.MoveEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 Structure (eidolons.entity.obj.Structure)1 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 UnitAI (eidolons.game.battlecraft.ai.UnitAI)1