Search in sources :

Example 26 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class GammaMaster method getAlphaForShadowMapCell.

public float getAlphaForShadowMapCell(int x, int y, SHADE_LIGHT type) {
    if (type == SHADE_LIGHT.BLACKOUT) {
        return getBlackoutAlpha(x, y);
    }
    if (type == SHADE_LIGHT.HIGLIGHT) {
        return getHiglightAlpha(x, y);
    }
    Unit unit = Eidolons.game.getManager().getMainHero();
    if (unit == null) {
        unit = Eidolons.game.getManager().getActiveObj();
    }
    if (unit == null) {
        switch(type) {
            case GAMMA_SHADOW:
                return 1;
        }
        return 0;
    }
    float alpha = 0;
    float gamma = getGammaForCell(x, y);
    switch(type) {
        case GAMMA_SHADOW:
            if (VisionManager.isVisionHacked()) {
                return 0;
            }
            if (gamma >= 1)
                return 0;
            if (gamma < 0)
                alpha = 1;
            else
                alpha = 1 - gamma;
            if (unit.getX() == x && unit.getY() == y) {
                alpha = alpha / 2;
            }
            break;
        case GAMMA_LIGHT:
            if (gamma < 0)
                return 0;
            alpha = (float) Math.min(Math.sqrt(gamma * 2), gamma / 3);
            alpha = Math.min(alpha, 0.5f);
            break;
        case LIGHT_EMITTER:
            for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
                if (sub instanceof Unit)
                    // TODO illuminate some other way for units...
                    continue;
                if (sub.getCoordinates().x == x)
                    if (sub.getCoordinates().y == y)
                        if (((DC_Obj) sub).getPlayerVisionStatus(false) == PLAYER_VISION.DETECTED) {
                            alpha += LIGHT_EMITTER_ALPHA_FACTOR * master.getGame().getRules().getIlluminationRule().getLightEmission((DC_Obj) sub);
                        }
            }
            if (alpha > 0) {
                break;
            }
            break;
        case CONCEALMENT:
            alpha = // PARAMS.CONCEALMENT)*CONCEALMENT_ALPHA_FACTOR;
            master.getIlluminationMaster().getConcealment(unit, Eidolons.game.getCellByCoordinate(new Coordinates(x, y))) * CONCEALMENT_ALPHA_FACTOR;
            if (alpha > 0)
                alpha += getAlphaForShadowMapCell(x, y, SHADE_LIGHT.LIGHT_EMITTER) / 3;
            break;
    }
    return MathMaster.minMax(alpha, 0, 1);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 27 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class Analyzer method getWanderCells.

public static List<? extends DC_Obj> getWanderCells(UnitAI ai) {
    DIRECTION d = ai.getGroup().getWanderDirection();
    // permittedCells = ai.getGroup().getWanderBlocks();
    List<DC_Obj> list = new ArrayList<>();
    for (DC_Cell cell : getCells(ai, false, false, true)) {
        if (d != null) {
            if (DirectionMaster.getRelativeDirection(cell, ai.getUnit()) != d) {
                continue;
            }
        }
        if (PositionMaster.getDistance(cell, ai.getUnit()) <= ai.getMaxWanderDistance()) {
            list.add(cell);
        }
    }
    if (list.isEmpty()) {
    // change direction?
    }
    return list;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Example 28 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class DC_GameManager method select.

@Override
public Integer select(Set<Obj> selectingSet, Ref ref) {
    Pair<Set<Obj>, TargetRunnable> p = new ImmutablePair<>(selectingSet, (t) -> {
        if (ref.getActive() instanceof DC_ActiveObj) {
            // TODO CLICK ON ANY OTHER OBJ MUST RESULT IN SELECTION STOP!
            // ((DC_ActiveObj) ref.getActive()).activateOn(t);
            // WaitMaster.receiveInput(WAIT_OPERATIONS.SELECT_BF_OBJ, t.getId());
            t.invokeClicked();
        }
    });
    GuiEventManager.trigger(SELECT_MULTI_OBJECTS, p);
    for (Obj obj : new ArrayList<>(selectingSet)) {
        if (obj instanceof DC_Obj) {
            DC_Obj unit = (DC_Obj) obj;
            if (getActiveObj() != null) {
                if (getActiveObj().getZ() != unit.getZ()) {
                    selectingSet.remove(unit);
                }
            }
        }
    }
    this.selectingSet = selectingSet;
    if (selectingSet.isEmpty()) {
        // getGame().getToolTipMaster().addTooltip(SCREEN_POSITION.ACTIVE_UNIT_BOTTOM,
        // "No targets available!");
        DC_SoundMaster.playStandardSound(STD_SOUNDS.ACTION_CANCELLED);
        return null;
    }
    setSelecting(true);
    for (Obj obj : selectingSet) {
        DrawMasterStatic.getObjImageCache().remove(obj);
    }
    Integer id = selectAwait();
    if (id == null) {
        if (ref.getTarget() != null) {
            return ref.getTarget();
        }
    }
    return id;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Set(java.util.Set) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) MicroObj(main.entity.obj.MicroObj) ActiveObj(main.entity.obj.ActiveObj) BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj) ArrayList(java.util.ArrayList) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) TargetRunnable(eidolons.libgdx.bf.TargetRunnable)

Example 29 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class Level method getFacingMapData.

private String getFacingMapData() {
    String facingMapData = "";
    Map<Coordinates, List<Unit>> multiMap = new HashMap<>();
    for (Coordinates c : getDirectionMap().keySet()) {
        Map<BattleFieldObject, DIRECTION> map = getDirectionMap().get(c);
        for (DC_Obj obj : map.keySet()) {
            if (obj instanceof Unit) {
                Unit u = (Unit) obj;
                DIRECTION facing = map.get(u);
                if (facing != null) {
                    u.setCoordinates(c);
                    String string = DC_ObjInitializer.getObjString(u);
                    List<Unit> list = multiMap.get(c);
                    if (list == null) {
                        list = new ArrayList<>();
                        multiMap.put(c, list);
                    }
                    list.add(u);
                    if (list.size() > 1) {
                        string += list.size() + 1;
                    }
                    facingMapData += RandomWizard.getWeightStringItem(string, facing.toString());
                }
            }
        }
    }
    return facingMapData;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) HashMap(java.util.HashMap) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList) List(java.util.List) Unit(eidolons.entity.obj.unit.Unit)

Example 30 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class WatchActionEffect method applyThis.

@Override
public boolean applyThis() {
    Obj sourceObj = ref.getSourceObj();
    List<DC_Obj> list = WatchRule.getWatchersMap().get(sourceObj);
    if (list == null) {
        list = new ArrayList<>();
        WatchRule.getWatchersMap().put((Unit) sourceObj, list);
    } else if (!alert) {
        if (list.contains(ref.getTargetObj())) {
            list.remove(ref.getTargetObj());
            if (RandomWizard.random()) {
                DC_SoundMaster.playStandardSound(STD_SOUNDS.BACK);
            } else {
                DC_SoundMaster.playStandardSound(STD_SOUNDS.CLOSE);
            }
            LogMaster.log(1, sourceObj.getName() + " no longer watching " + ref.getTargetObj().getNameIfKnown());
            return true;
        } else if (!list.isEmpty()) {
            if (RandomWizard.random()) {
                DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__BLOCKED);
            } else {
                DC_SoundMaster.playStandardSound(STD_SOUNDS.CLICK_ERROR);
            }
            // if (maxUnitsWatched<=1)
            return false;
        }
    }
    list.add((DC_Obj) ref.getTargetObj());
    if (!alert) {
        if (// (sourceObj.isMine())
        RandomWizard.random()) {
            DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__KNIFE);
        } else {
            DC_SoundMaster.playStandardSound(STD_SOUNDS.NOTE);
        }
    }
    return true;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj)

Aggregations

DC_Obj (eidolons.entity.obj.DC_Obj)49 Unit (eidolons.entity.obj.unit.Unit)13 Obj (main.entity.obj.Obj)13 Coordinates (main.game.bf.Coordinates)12 ArrayList (java.util.ArrayList)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 DIRECTION (main.game.bf.Coordinates.DIRECTION)7 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)5 DC_Cell (eidolons.entity.obj.DC_Cell)4 BufferedImage (java.awt.image.BufferedImage)4 List (java.util.List)3 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 HashMap (java.util.HashMap)2 PARAMETER (main.content.values.parameters.PARAMETER)2 Ref (main.entity.Ref)2 BuffObj (main.entity.obj.BuffObj)2 Pair (org.apache.commons.lang3.tuple.Pair)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1