Search in sources :

Example 16 with Coordinates

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

the class OccupiedCondition method check.

@Override
public boolean check(Ref ref) {
    Coordinates c = getCoordinates(ref);
    if (c == null) {
        return true;
    }
    boolean result;
    if (permitCollision) {
        result = !game.getMovementManager().getPathingManager().isGroundPassable(ref.getSourceObj(), c);
    } else {
        result = game.getMovementManager().getPathingManager().isOccupied(c);
    }
    // .getObjCompMap().get(c);
    if (result) {
        for (Obj obj : game.getObjectsOnCoordinate(c)) {
            if (game.getVisionMaster().checkInvisible(obj)) {
                if (permitInvisCollision) {
                    result = false;
                    continue;
                }
            }
            try {
                if (ref.getSourceObj().checkProperty(G_PROPS.STANDARD_PASSIVES, "" + UnitEnums.STANDARD_PASSIVES.FLYING)) {
                    if (obj.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
                        if (obj.checkProperty(G_PROPS.STANDARD_PASSIVES, "" + UnitEnums.STANDARD_PASSIVES.TALL)) {
                            result = false;
                        }
                        continue;
                    }
                }
            } catch (Exception e) {
            }
            return true;
        }
    }
    return result;
}
Also used : Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates)

Example 17 with Coordinates

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

the class ShapeEffect method initTargeting.

@Override
public void initTargeting() {
    // init unit group
    Coordinates baseCoordinate = getBaseCoordinate();
    int base_width = radius.getInt(ref);
    int distance = this.distance.getInt(ref);
    coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
    DequeImpl<Obj> objects = new DequeImpl<>();
    objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
    Filter.filter(objects, targetType);
    if (allyOrEnemyOnly != null) {
        if (allyOrEnemyOnly) {
            FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
        } else {
            FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
        }
    }
    if (notSelf) {
        FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
    }
    if (targetType.equals(DC_TYPE.TERRAIN)) {
        // C_TYPE equals if contains() !
        objects.addAll(game.getCellsForCoordinates(coordinates));
    }
    targeting = new AutoTargeting(new GroupImpl(objects));
    setFilteringConditions(new Conditions());
    targeting.setConditions(getFilteringConditions());
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) DequeImpl(main.system.datatypes.DequeImpl) Conditions(main.elements.conditions.Conditions)

Example 18 with Coordinates

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

the class StackingRule method canBeMovedOnto.

private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
    HashMap<Coordinates, Boolean> bools = cache.get(unit);
    boolean result = false;
    if (maxSpaceTakenPercentage == 100) {
        if (bools != null) {
            if (bools.containsKey(c)) {
                return bools.get(c);
            }
        } else {
            bools = new HashMap<>();
            cache.put(unit, bools);
        }
    }
    // get all units on the cell
    DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
    for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
        if (!units.contains(u)) {
            if (!u.isAnnihilated())
                // continue; TODO why was Type necessary?
                units.addCast(!u.isDead() ? u.getType() : u);
            if (u.isWall())
                if (!u.isDead())
                    return false;
        }
    }
    // check if '1 unit per cell' is on
    if (maxSpaceTakenPercentage <= 0) {
        if (!units.isEmpty()) {
            return false;
        }
    }
    if (unit == null) {
        unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
    }
    Obj cell;
    if (!game.isSimulation()) {
        cell = game.getCellByCoordinate(c);
    } else {
        cell = new DC_Cell(c, game);
    }
    if (cell == null) {
        return false;
    }
    if (z == null) {
        if (unit instanceof Unit) {
            Unit heroObj = (Unit) unit;
            z = heroObj.getZ();
        }
    }
    // TODO ???
    if (game.isSimulation()) {
        if (units.size() > 1) {
            return false;
        }
    }
    // no passable/overlaying!
    int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
    if (c != null) {
        if (!game.isSimulation()) {
            space = cell.getIntParam(PARAMS.SPACE);
        }
    }
    int girth = 0;
    for (Entity u : units) {
        if (u == unit) {
            continue;
        }
        // }
        if (UnitAnalyzer.isWall(u)) {
            // if (!UnitAnalyzer.isFlying(unit)) {
            return false;
        // }
        }
        if (u.isDead())
            girth += u.getIntParam(PARAMS.GIRTH) / 3;
        else
            girth += u.getIntParam(PARAMS.GIRTH);
    // TODO  if (DoorMaster.isDoor((BattleFieldObject) u)) {
    // 
    // }
    // main.system.auxiliary.LogMaster.log(1, "****************** " +
    // u.getName()
    // + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
    }
    // [QUICK FIX]
    if (unit.getIntParam(PARAMS.GIRTH) == 0) {
        girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
    } else {
        girth += unit.getIntParam(PARAMS.GIRTH);
    }
    // main.system.auxiliary.LogMaster.log(1, "****************** " + space
    // + " Space vs " + girth
    // + " Girth on " + c + " for " + unit);
    space = space * maxSpaceTakenPercentage / 100;
    if (space >= girth) {
        result = true;
    } else {
        if (unit.getIntParam(PARAMS.GIRTH) > space) {
            if (units.isEmpty()) {
                result = true;
            }
        }
    }
    if (// only cache for default cases!
    maxSpaceTakenPercentage == 100) {
        bools.put(c, result);
    }
    return result;
}
Also used : Entity(main.entity.Entity) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Cell(eidolons.entity.obj.DC_Cell) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DequeImpl(main.system.datatypes.DequeImpl)

Example 19 with Coordinates

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

the class ActionAnimation method drawActivate.

protected boolean drawActivate(AnimPhase phase) {
    if (action.isAttackOrStandardAttack()) {
        return false;
    }
    Image image = action.getIcon().getImage();
    Coordinates c = getTargetCoordinates();
    if (c == null) {
        c = getSourceCoordinates();
    }
    // TODO can we getOrCreate the cellComp's graphics?
    int zoom = action.getGame().getBattleField().getGrid().getGridComp().getZoom();
    int h = GuiManager.getCellHeight() * zoom / 100;
    int w = GuiManager.getCellWidth() * zoom / 100;
    Point point = action.getGame().getBattleField().getGrid().getGridComp().getPointForCoordinateWithOffset(c);
    int x = (int) (point.getX() + (w - image.getWidth(null)) / 2);
    int y = (int) (point.getY() + (h - image.getHeight(null)) / 2);
    // try it!
    g.drawImage(image, x, y, null);
    return true;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 20 with Coordinates

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

the class AnimationManager method updatePoints.

public Coordinates updatePoints(List<PhaseAnimation> anims) {
    for (PhaseAnimation anim : anims) {
        boolean result = anim.updatePoints();
        if (!result) {
            if (anim.isCameraPanningOn()) {
                pendingCameraAdjustmentAnims.add(anim);
            // see what anims are beyond the edges for current offset
            }
        // find the minimum number of omitted anims?
        // usage cases - replaying mass-anims or single anims -
        // centering ;
        }
    }
    if (pendingCameraAdjustmentAnims.isEmpty()) {
        return bufferedOffset;
    }
    offset = game.getBattleField().getGrid().getOffsetCoordinate();
    if (offset == null) {
        offset = new Coordinates(0, 0);
    }
    int y = offset.y;
    int x = offset.x;
    int y1 = offset.y;
    int x1 = offset.x;
    int minNumber = getMinNumberOfAnimsOutOfBounds(y, x, y1, x1, true);
    Coordinates bufferedCoordinate = offset;
    int minNumber2 = getMinNumberOfAnimsOutOfBounds(y, x, y1, x1, false);
    if (minNumber < minNumber2) {
        offset = bufferedCoordinate;
    }
    adjustOffset(offset);
    return bufferedOffset;
}
Also used : Coordinates(main.game.bf.Coordinates)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5