Search in sources :

Example 1 with BfObj

use of main.entity.obj.BfObj in project Eidolons by IDemiurge.

the class VisibilityCondition method check.

@Override
public boolean check(Ref ref) {
    if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
        return false;
    }
    DC_Obj match = (DC_Obj) ref.getObj(KEYS.MATCH);
    boolean result = false;
    if (this.match == null && this.source == null) {
        if (p_vision != null) {
            PLAYER_VISION playerVision = match.getActivePlayerVisionStatus();
            if (game.getManager().getActiveObj().isMine() != ref.getSourceObj().isMine()) {
                if (ref.getSourceObj().isMine()) {
                    playerVision = match.getPlayerVisionStatus(false);
                } else {
                // TODO for enemy unit on player's unit...
                }
            }
            if (playerVision == p_vision) {
                return true;
            }
        }
        UNIT_VISION visionStatus = match.getUnitVisionStatus();
        if (!ref.getSourceObj().isActiveSelected()) {
            visionStatus = match.getGame().getVisionMaster().getSightMaster().getUnitVisibilityStatus(match, (Unit) ref.getSourceObj());
        }
        return visionStatus.isSufficient(u_vision);
    }
    if (p_vision != null) {
        Unit unit = (Unit) ref.getObj(source);
        result = unit.getActivePlayerVisionStatus() == p_vision;
    } else if (u_vision != null) {
        match = (DC_Obj) ref.getObj(this.match);
        // if (((DC_Game) game).getManager().isAI_Turn()) { what's the idea?
        Unit activeObj = (Unit) ref.getObj(source);
        result = ((DC_Game) game).getVisionMaster().getUnitVisibilityStatus(match, activeObj).isSufficient(u_vision);
    // }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) PLAYER_VISION(main.content.enums.rules.VisionEnums.PLAYER_VISION) UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) BfObj(main.entity.obj.BfObj) DC_Game(eidolons.game.core.game.DC_Game) Unit(eidolons.entity.obj.unit.Unit)

Example 2 with BfObj

use of main.entity.obj.BfObj in project Eidolons by IDemiurge.

the class ChangeFacingEffect method applyThis.

@Override
public boolean applyThis() {
    if (!(ref.getTargetObj() instanceof Unit)) {
        return false;
    }
    Unit obj = (Unit) ref.getTargetObj();
    FACING_DIRECTION oldDirection = obj.getFacing();
    FACING_DIRECTION newDirection = null;
    if (isClockwise() == null) {
        for (FACING_DIRECTION f : FACING_DIRECTION.values()) {
            Obj active = ref.getObj(KEYS.ACTIVE);
            if (active == null) {
                return false;
            }
            if (FacingMaster.getSingleFacing(f, obj, (BfObj) active.getRef().getTargetObj()) == UnitEnums.FACING_SINGLE.IN_FRONT) {
                newDirection = f;
                break;
            }
        }
    } else {
        newDirection = FacingMaster.rotate(oldDirection, isClockwise());
    }
    obj.setFacing(newDirection);
    game.fireEvent(new Event(getEventTypeDone(), ref));
    return true;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) BfObj(main.entity.obj.BfObj) Obj(main.entity.obj.Obj) BfObj(main.entity.obj.BfObj) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit)

Example 3 with BfObj

use of main.entity.obj.BfObj in project Eidolons by IDemiurge.

the class FacingCondition method check.

@Override
public boolean check(Ref ref) {
    if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
        return false;
    }
    BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
    DC_Obj obj2;
    if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
        if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
            return false;
        }
        obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
    } else {
        obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
    }
    boolean result = false;
    if (getTemplate() != null) {
        Coordinates c = obj2.getCoordinates();
        if (obj2.isOverlaying())
            if (obj2 instanceof BattleFieldObject) {
                DIRECTION d = ((BattleFieldObject) obj2).getDirection();
                if (d != null) {
                    c = c.getAdjacentCoordinate(d.rotate180(), 2);
                }
            // the coordinate to which unit must be facing in order to face the overlaying obj on the other side
            }
        if (obj1 == null)
            return false;
        if (c == null)
            return false;
        FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
        result = Arrays.asList(templates).contains(facing);
        if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
            if (result) {
                if (left_right == null) {
                    left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
                }
                if (left_right) {
                    int degrees = obj1.getFacing().getDirection().getDegrees();
                    int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
                    boolean left = degrees > degrees2;
                    if (left) {
                        return left_right;
                    }
                    return !left_right;
                }
            }
        }
    }
    return result;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) BfObj(main.entity.obj.BfObj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Aggregations

BfObj (main.entity.obj.BfObj)3 DC_Obj (eidolons.entity.obj.DC_Obj)2 Unit (eidolons.entity.obj.unit.Unit)2 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)1 DC_Game (eidolons.game.core.game.DC_Game)1 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)1 PLAYER_VISION (main.content.enums.rules.VisionEnums.PLAYER_VISION)1 UNIT_VISION (main.content.enums.rules.VisionEnums.UNIT_VISION)1 Obj (main.entity.obj.Obj)1 Coordinates (main.game.bf.Coordinates)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)1 Event (main.game.logic.event.Event)1