Search in sources :

Example 31 with DIRECTION

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

the class CoordinateTargeting method select.

public boolean select(Ref ref) {
    DC_Obj obj = (DC_Obj) ref.getObj(key);
    DIRECTION used_direction = direction;
    if (unitDirection != null) {
        Unit unit = (Unit) obj;
        used_direction = DirectionMaster.getDirectionByFacing(unit.getFacing(), unitDirection);
    }
    Coordinates coordinate = obj.getCoordinates().getAdjacentCoordinate(used_direction);
    List<BattleFieldObject> objects = obj.getGame().getMaster().getObjectsOnCoordinate(coordinate, false);
    if (objects.size() == 0) {
        ref.setTarget(obj.getGame().getCellByCoordinate(coordinate).getId());
    } else if (objects.size() == 1) {
        ref.setTarget(objects.get(0).getId());
    } else {
        ref.setGroup(new GroupImpl(new ArrayList<>(objects)));
    }
    return true;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) UNIT_DIRECTION(main.game.bf.Coordinates.UNIT_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates) GroupImpl(main.entity.group.GroupImpl) Unit(eidolons.entity.obj.unit.Unit)

Example 32 with DIRECTION

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

the class ShadeLightCell method adjustPosition.

public void adjustPosition(int x, int y) {
    float offsetX = 0;
    float offsetY = 0;
    setScale(1f, 1f);
    setVisible(true);
    for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
        if (sub instanceof Unit)
            // TODO illuminate some other way for units...
            continue;
        if (sub instanceof Structure) {
            if (sub.getCoordinates().x == x)
                if (sub.getCoordinates().y == y)
                    if (((Structure) sub).isOverlaying()) {
                        DIRECTION d = ((Structure) sub).getDirection();
                        if (d == null) {
                            setScale(0.7f, 0.7f);
                            continue;
                        }
                        setScale(d.growX == null ? 1 : 0.8f, d.growY == null ? 1 : 0.8f);
                        Dimension dim = GridMaster.getOffsetsForOverlaying(d, (int) getWidth() - 64, (int) getHeight() - 64);
                        offsetX += dim.width;
                        offsetY += dim.height;
                    // so if 2+ overlays, will be centered between them...
                    } else {
                        BaseView view = DungeonScreen.getInstance().getGridPanel().getViewMap().get(sub);
                        offsetX += view.getX() * 3;
                        offsetY += view.getY() * 3;
                        if (view.getParent() instanceof GridCellContainer) {
                            if ((((GridCellContainer) view.getParent()).getUnitViews(true).size() > 1)) {
                                if (!view.isHovered())
                                    setVisible(false);
                            }
                        }
                    }
        }
    }
    setPosition(originalX + offsetX / 3, originalY + offsetY / 3);
}
Also used : Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) GridCellContainer(eidolons.libgdx.bf.grid.GridCellContainer) BaseView(eidolons.libgdx.bf.grid.BaseView) Unit(eidolons.entity.obj.unit.Unit) Structure(eidolons.entity.obj.Structure)

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