Search in sources :

Example 11 with DIRECTION

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

the class WanderAi method changeGroupMoveDirection.

public static void changeGroupMoveDirection(GroupAI group, GOAL_TYPE type) {
    DIRECTION wanderDirection = group.getWanderDirection();
    if (type == AiEnums.GOAL_TYPE.PATROL) {
        // one-way-turn
        if (// GUARD?
        group.isBackAndForth()) {
            wanderDirection = DirectionMaster.rotate90(DirectionMaster.rotate90(wanderDirection, true), true);
        } else {
            wanderDirection = DirectionMaster.rotate90(wanderDirection, group.isClockwisePatrol());
        }
    } else if (type == AiEnums.GOAL_TYPE.WANDER) {
        if (PositionMaster.getDistance(group.getOriginCoordinates(), group.getLeader().getCoordinates()) >= getMaxWanderTotalDistance(group, type)) {
            wanderDirection = DirectionMaster.getRelativeDirection(group.getLeader().getCoordinates(), group.getOriginCoordinates());
        }
    }
    if (wanderDirection == group.getWanderDirection()) {
        if (RandomWizard.random() || RandomWizard.random()) {
            wanderDirection = DirectionMaster.rotate45(wanderDirection, RandomWizard.random());
        } else {
            wanderDirection = DirectionMaster.rotate90(wanderDirection, RandomWizard.random());
        }
    }
    // if () //TODO change of opposite!
    // DirectionMaster.getDirectionByDegree(degrees);
    // getOrCreate direction by Leader's facing at the time, and make him
    // turn and turn while waiting!
    group.setWanderDirection(wanderDirection);
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION)

Example 12 with DIRECTION

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

the class WanderAi method getWanderTargetCoordinatesCell.

public static Coordinates getWanderTargetCoordinatesCell(UnitAI ai, GOAL_TYPE type) {
    // List<? extends DC_Obj> cells = getWanderCells(ai);
    // ai.getStandingOrders(); TODO set target???
    // // from original coordinate? Or 'last'?
    // ai.getGroup().getWanderDistance();
    boolean follow = ai.getGroup().isFollowLeader() || isFollowLeader(type);
    if (follow) {
        if (isAheadOfLeader(ai)) {
            return null;
        }
    }
    DIRECTION direction = ai.getGroup().getWanderDirection();
    // DirectionMaster.getRelativeDirection(source, target);
    if (direction == null) {
        return null;
    }
    Coordinates c = ai.getUnit().getCoordinates().getAdjacentCoordinate(direction);
    return c;
// auto-turn if facing ain't right? take relative *position*
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates)

Example 13 with DIRECTION

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

the class DC_BattleFieldManager method resetWalls.

public void resetWalls() {
    doorMap.clear();
    Map<Coordinates, BattleFieldObject> wallObjects = new HashMap<>();
    for (Obj obj : game.getObjects(DC_TYPE.BF_OBJ)) {
        BattleFieldObject bfObj = (BattleFieldObject) obj;
        if (bfObj.getZ() == game.getDungeon().getZ()) {
            if (bfObj.isWall()) {
                wallObjects.put(obj.getCoordinates(), bfObj);
            }
            if (bfObj instanceof Door) {
                doorMap.put(obj.getCoordinates(), ((Door) bfObj).getState());
            }
        }
    }
    if (wallMap == null) {
        wallMap = new HashMap<>();
    }
    wallMap.clear();
    ArrayList<Coordinates> coordinates = new ArrayList<>(wallObjects.keySet());
    for (Coordinates coordinate : coordinates) {
        BattleFieldObject wall = wallObjects.get(coordinate);
        if (wall.isDead()) {
            continue;
        }
        List<DIRECTION> list = new ArrayList<>();
        for (Coordinates c : coordinate.getAdjacent(false)) {
            BattleFieldObject adjWall = wallObjects.get(c);
            if (adjWall != null) {
                if (adjWall.isWall() && !adjWall.isDead()) {
                    DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
                    list.add(side);
                }
            }
        }
        adjacent: for (Coordinates c : coordinate.getAdjacent(true)) {
            BattleFieldObject adjWall = wallObjects.get(c);
            if (adjWall != null) {
                if (adjWall.isWall() && !adjWall.isDead()) {
                    DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
                    if (!side.isDiagonal()) {
                        continue;
                    }
                    for (DIRECTION s : list) {
                        if (s.isDiagonal()) {
                            continue;
                        }
                        if (side.getXDirection() == s) {
                            continue adjacent;
                        }
                        if (side.getYDirection() == s) {
                            continue adjacent;
                        }
                    }
                    list.add(side);
                }
            }
        }
        if (!list.isEmpty()) {
            if (coordinate == null)
                continue;
            wallMap.put(coordinate, list);
        }
    }
    if (diagonalJoints == null) {
        diagonalJoints = new HashMap<>();
    }
    diagonalJoints.clear();
    loop: for (Coordinates c : wallMap.keySet()) {
        for (DIRECTION s : wallMap.get(c)) {
            if (s.isDiagonal()) {
                // for (Coordinates c :
                // o.getCoordinates().getAdjacentCoordinates(null)) {
                // if (wallObjects.get(c) != null) {
                // if (containsAdjacentDiagonal in X direction
                // }
                // }
                List<DIRECTION> list = diagonalJoints.get(c);
                if (list == null) {
                    list = new ArrayList<>();
                }
                diagonalJoints.put(c, list);
                if (list.size() == 1) {
                    DIRECTION d = list.get(0);
                    if (s.growX)
                        if (!d.growX)
                            continue;
                        else if (d.growX)
                            continue;
                    if (s.growY)
                        if (!d.growY)
                            continue;
                        else if (d.growY)
                            continue;
                }
                list.add(s);
                continue loop;
            }
        }
    }
    wallResetRequired = false;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) Door(eidolons.game.module.dungeoncrawl.objects.Door)

Example 14 with DIRECTION

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

the class SightMaster method addSides.

private void addSides(DequeImpl<Coordinates> list, Coordinates orig, DIRECTION facing, int range, boolean remove) {
    DIRECTION side = DirectionMaster.rotate90(facing, true);
    addLine(orig.getAdjacentCoordinate(side), range, list, side, false, remove);
    side = DirectionMaster.rotate90(facing, false);
    addLine(orig.getAdjacentCoordinate(side), range, list, side, false, remove);
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Example 15 with DIRECTION

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

the class SightMaster method getSpectrumCoordinates.

public DequeImpl<Coordinates> getSpectrumCoordinates(Integer range, Integer side_penalty, Integer back_bonus, BattleFieldObject source, boolean vision, FACING_DIRECTION facing, boolean extended) {
    DequeImpl<Coordinates> list = new DequeImpl<>();
    BattleFieldObject unit = null;
    Coordinates orig = source.getCoordinates();
    if (source instanceof BattleFieldObject) {
        unit = (BattleFieldObject) source;
    }
    if (facing == null) {
        if (unit != null) {
            facing = unit.getFacing();
        }
    }
    DIRECTION direction;
    if (facing == null) {
        facing = FacingMaster.getRandomFacing();
    }
    direction = facing.getDirection();
    if (range == null) {
        range = source.getIntParam(PARAMS.SIGHT_RANGE);
        if (extended) {
            range = MathMaster.applyModIfNotZero(range, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION));
        }
    }
    if (side_penalty == null) {
        side_penalty = source.getIntParam(PARAMS.SIDE_SIGHT_PENALTY);
        if (extended) {
            side_penalty = MathMaster.applyModIfNotZero(side_penalty, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_SIDES));
        }
    }
    if (back_bonus == null) {
        back_bonus = source.getIntParam(PARAMS.BEHIND_SIGHT_BONUS);
        if (!extended)
            back_bonus--;
    // back_bonus = MathMaster.applyModIfNotZero(back_bonus, source
    // .getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_BACKWARD));
    }
    addLine(orig.getAdjacentCoordinate(direction), range, list, direction, true);
    addSides(list, orig, direction, range - side_penalty, false);
    DIRECTION backDirection = DirectionMaster.flip(direction);
    Coordinates backCoordinate = orig.getAdjacentCoordinate(backDirection);
    if (back_bonus > 0) {
        if (backCoordinate != null) {
            addLine(backCoordinate, back_bonus, list, backDirection, true);
        // if (back_bonus > side_penalty)
        // addSides(list, backCoordinate, backDirection, back_bonus -
        // side_penalty, false);
        }
    }
    Collection<Coordinates> blocked = getBlockedList(list, source, facing);
    list.removeAll(blocked);
    list.add(source.getCoordinates());
    return list;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) DequeImpl(main.system.datatypes.DequeImpl)

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