Search in sources :

Example 31 with BattleFieldObject

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

the class IlluminationRule method getLightEmissionEffect.

public LightEmittingEffect getLightEmissionEffect(DC_Obj source) {
    LightEmittingEffect effect = effectCache.get(source);
    if (effect == null) {
        int value = getLightEmission(source);
        if (value <= 0) {
            return null;
        }
        Boolean circular = true;
        if (source instanceof Unit)
            circular = false;
        else if (source.checkBool(GenericEnums.STD_BOOLS.SPECTRUM_LIGHT)) {
            circular = false;
        } else if (EntityCheckMaster.isOverlaying(source)) {
            BattleFieldObject dc_Obj = (BattleFieldObject) source;
            if (dc_Obj.getDirection() != null) {
                circular = false;
            }
        }
        effect = new LightEmittingEffect(("" + value), circular);
        effect.setRef(new Ref(source));
        effectCache.put(source, effect);
    } else
        effect.getEffects().setFormula(new Formula("" + getLightEmission(source)));
    return effect;
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Unit(eidolons.entity.obj.unit.Unit) LightEmittingEffect(eidolons.ability.effects.common.LightEmittingEffect)

Example 32 with BattleFieldObject

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

the class ClearShotCondition method check.

@Override
public boolean check(Ref ref) {
    Obj obj = game.getObjectById(ref.getId(str2));
    if (!(obj instanceof DC_Obj)) {
        return false;
    }
    DC_Obj target = (DC_Obj) game.getObjectById(ref.getId(str2));
    if (target == null) {
        return false;
    }
    Coordinates c2 = target.getCoordinates();
    if (c2 == null)
        return false;
    BattleFieldObject source = (BattleFieldObject) game.getObjectById(ref.getId(str1));
    if (source == null)
        return false;
    if (c2.equals(source.getCoordinates()))
        return true;
    if (target.isOverlaying()) {
        if (target instanceof BattleFieldObject) {
            DIRECTION d = ((BattleFieldObject) target).getDirection();
            DIRECTION d1 = DirectionMaster.getRelativeDirection(target, source);
            if (d != null) {
                if (d1 != d) {
                    if (Math.abs(d.getDegrees() - d1.getDegrees()) > 90)
                        return false;
                }
            }
        }
    }
    wallObstruction = false;
    Coordinates c1 = source.getCoordinates();
    boolean toCheck = true;
    boolean result = true;
    if (PositionMaster.inLine(c1, c2)) {
        result = PositionMaster.noObstaclesInLine(source, target, game.getBattleField().getGrid());
        toCheck = false;
        if (!result)
            return cacheResult(source, target, result);
    } else {
        // TODO TRANSPARENT FOR VISION!
        if (PositionMaster.inLineDiagonally(c1, c2)) {
            result = PositionMaster.noObstaclesInDiagonal(c1, c2, game.getBattleField().getGrid(), source);
            if (!result)
                return cacheResult(source, target, result);
            List<Coordinates> list = new ArrayList<>();
            if (!c2.isAdjacent(source.getCoordinates())) {
                DIRECTION direction = DirectionMaster.getRelativeDirection(source, target);
                list = (DC_PositionMaster.getLine(false, direction, source.getCoordinates(), // PositionMaster.getDistance(source,
                Math.abs(source.getX() - target.getX())));
            } else {
                list.add(target.getCoordinates());
            }
            for (Coordinates c : list) {
                if (checkWallObstruction(source, target, c))
                    return cacheResult(source, target, false);
            }
            return cacheResult(source, target, true);
        }
    }
    if (!result)
        return cacheResult(source, target, result);
    if (!toCheck)
        return cacheResult(source, target, result);
    result = checkClearShot(source, target);
    return cacheResult(source, target, result);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Example 33 with BattleFieldObject

use of eidolons.entity.obj.BattleFieldObject 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)

Example 34 with BattleFieldObject

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

the class DungeonBuilder method initDynamicObjData.

protected void initDynamicObjData(Location location, DungeonPlan plan) {
    int z = location.getIntParam(G_PARAMS.Z_LEVEL);
    for (MapBlock b : plan.getBlocks()) {
        ArrayList<Obj> objects = new ArrayList<>(b.getObjects());
        for (Obj obj : objects) {
            // TODO of course - the issue was that I added an object to
            // block too! ... init?
            BattleFieldObject unit = (BattleFieldObject) obj;
            if (z != 0) {
                unit.setZ(z);
            }
        }
    }
    for (MapZone zone : plan.getZones()) {
        ObjType wallType = DataManager.getType(zone.getFillerType(), DC_TYPE.BF_OBJ);
        if (wallType == null)
            continue;
        List<Coordinates> list = zone.getCoordinates();
        for (MapBlock b : zone.getBlocks()) {
            list.removeAll(b.getCoordinates());
        }
        for (Coordinates c : list) {
            getGame().getManager().getObjCreator().createUnit(wallType, c.x, c.y, Player.NEUTRAL, new Ref(game));
        }
    }
    for (Obj obj : plan.getWallObjects()) {
        BattleFieldObject unit = (BattleFieldObject) obj;
        if (z != 0) {
            unit.setZ(z);
        }
    }
    if (plan.getDirectionMap() != null) {
        try {
            DC_ObjInitializer.initDirectionMap(z, plan.getDirectionMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (plan.getFlipMap() != null) {
        try {
            DC_ObjInitializer.initFlipMap(z, plan.getFlipMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 35 with BattleFieldObject

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

the class DC_StateManager method removeObject.

public void removeObject(Integer id) {
    Obj obj = game.getObjectById(id);
    if (obj == null) {
        return;
    }
    if (obj instanceof BattleFieldObject) {
        if (obj instanceof Structure) {
            getGame().getStructures().remove(obj);
        }
        if (obj instanceof Unit) {
            getGame().getUnits().remove(obj);
        }
        removeAttachedObjects((Unit) obj);
    }
    Map<Integer, Obj> map = state.getObjMaps().get(obj.getOBJ_TYPE_ENUM());
    if (map != null) {
        map.remove(id);
    }
// super.removeObject(id);
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) BuffObj(main.entity.obj.BuffObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) Structure(eidolons.entity.obj.Structure) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

BattleFieldObject (eidolons.entity.obj.BattleFieldObject)52 Unit (eidolons.entity.obj.unit.Unit)24 Coordinates (main.game.bf.Coordinates)22 DC_Obj (eidolons.entity.obj.DC_Obj)12 Ref (main.entity.Ref)12 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 Obj (main.entity.obj.Obj)9 DequeImpl (main.system.datatypes.DequeImpl)8 Event (main.game.logic.event.Event)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 DIRECTION (main.game.bf.Coordinates.DIRECTION)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Vector2 (com.badlogic.gdx.math.Vector2)4 Align (com.badlogic.gdx.utils.Align)4 Eidolons (eidolons.game.core.Eidolons)4 Gdx (com.badlogic.gdx.Gdx)3 Keys (com.badlogic.gdx.Input.Keys)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)3 Group (com.badlogic.gdx.scenes.scene2d.Group)3