Search in sources :

Example 1 with UNIT_VISION

use of main.content.enums.rules.VisionEnums.UNIT_VISION 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 UNIT_VISION

use of main.content.enums.rules.VisionEnums.UNIT_VISION in project Eidolons by IDemiurge.

the class OverlaysManager method drawOverlaysForCell.

private void drawOverlaysForCell(GridCellContainer container, int x, int y, Batch batch) {
    if (sightInfoDisplayed) {
        DC_Cell cell = observer.getGame().getMaster().getCellByCoordinate(new Coordinates(x, y));
        UNIT_VISION vision = cell.getUnitVisionStatus(observer);
        if (vision == null) {
            return;
        }
        switch(vision) {
            case IN_PLAIN_SIGHT:
                drawOverlay(container, IN_PLAIN_SIGHT, batch);
                break;
            case IN_SIGHT:
                drawOverlay(container, IN_SIGHT, batch);
                break;
            case BLOCKED:
                drawOverlay(container, BLOCKED, batch);
                break;
            case CONCEALED:
                drawOverlay(container, FOG_OF_WAR, batch);
                break;
        }
    }
}
Also used : UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) DC_Cell(eidolons.entity.obj.DC_Cell) Coordinates(main.game.bf.Coordinates)

Example 3 with UNIT_VISION

use of main.content.enums.rules.VisionEnums.UNIT_VISION in project Eidolons by IDemiurge.

the class SightMaster method resetUnitVision.

public void resetUnitVision(BattleFieldObject observer, DC_Obj unit) {
    UNIT_VISION status = getUnitVisionStatusPrivate(unit, (Unit) observer);
    master.getVisionController().getUnitVisionMapper().set(observer, unit, status);
}
Also used : UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION)

Example 4 with UNIT_VISION

use of main.content.enums.rules.VisionEnums.UNIT_VISION in project Eidolons by IDemiurge.

the class SightMaster method resetUnitVision.

private void resetUnitVision(BattleFieldObject observer, Collection<? extends Obj> units) {
    int maxDistance = observer.getIntParam(PARAMS.SIGHT_RANGE) * 2 + 1;
    for (Obj obj : units) {
        DC_Obj unit = (DC_Obj) obj;
        if (PositionMaster.getDistance(observer, obj) > maxDistance) {
            master.getVisionController().getUnitVisionMapper().set(observer, unit, null);
            continue;
        }
        UNIT_VISION status = getUnitVisionStatusPrivate(unit, (Unit) observer);
        master.getVisionController().getUnitVisionMapper().set(observer, unit, status);
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj)

Example 5 with UNIT_VISION

use of main.content.enums.rules.VisionEnums.UNIT_VISION in project Eidolons by IDemiurge.

the class VisionRule method visibility.

public VISIBILITY_LEVEL visibility(Unit source, DC_Obj object) {
    UNIT_VISION sight = controller.getUnitVisionMapper().get(source, object);
    boolean landmark = object instanceof Structure;
    switch(sight) {
        case IN_PLAIN_SIGHT:
            return VISIBILITY_LEVEL.CLEAR_SIGHT;
        case BLOCKED:
            // if
            return VISIBILITY_LEVEL.BLOCKED;
        case IN_SIGHT:
            if (landmark)
                if (controller.getDetectionMapper().get(source.getOwner(), object)) {
                    return VISIBILITY_LEVEL.CONCEALED;
                }
            return VISIBILITY_LEVEL.OUTLINE;
        case BEYOND_SIGHT:
            if (landmark) {
                if (controller.getDetectionMapper().get(source.getOwner(), object)) {
                    return VISIBILITY_LEVEL.CONCEALED;
                }
            }
    }
    return VISIBILITY_LEVEL.UNSEEN;
// TODO case CONCEALED:
// break;
}
Also used : UNIT_VISION(main.content.enums.rules.VisionEnums.UNIT_VISION) Structure(eidolons.entity.obj.Structure)

Aggregations

UNIT_VISION (main.content.enums.rules.VisionEnums.UNIT_VISION)6 DC_Cell (eidolons.entity.obj.DC_Cell)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 PLAYER_VISION (main.content.enums.rules.VisionEnums.PLAYER_VISION)2 Structure (eidolons.entity.obj.Structure)1 Unit (eidolons.entity.obj.unit.Unit)1 DC_Game (eidolons.game.core.game.DC_Game)1 VISIBILITY_LEVEL (main.content.enums.rules.VisionEnums.VISIBILITY_LEVEL)1 BfObj (main.entity.obj.BfObj)1 Obj (main.entity.obj.Obj)1 Coordinates (main.game.bf.Coordinates)1