Search in sources :

Example 31 with Obj

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

the class UpkeepRule method apply.

@Override
public void apply(Unit unit) {
    // TODO getOrCreate all buffs/units with this SOURCE /summoner
    List<Obj> payObjects = new ArrayList<>();
    List<Obj> destroyObjects = new ArrayList<>();
    boolean destroy = unit.isDead() || unit.isUnconscious();
    for (Unit u : game.getUnits()) {
        if (destroy || u.isDead() || u.isUnconscious()) {
            destroyObjects.add(u);
        } else if (u.getRef().getObj(KEYS.SUMMONER) == unit) {
            if (checkHasUpkeep(u)) {
                payObjects.add(u);
            }
        }
    }
    for (Obj buff : game.getObjects(DC_TYPE.BUFFS)) {
        try {
            Obj spell = (Obj) buff.getRef().getActive();
            if (spell == null) {
                continue;
            }
            if (spell.getRef().getSourceObj() == unit) {
                // TODO summoner?
                if (checkHasUpkeep(buff)) {
                    payObjects.add(buff);
                }
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    for (Obj payObj : destroyObjects) {
        enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
    }
    for (Obj payObj : payObjects) {
        if (!checkCanUpkeep(unit, payObj)) {
            // positive upkeep?
            enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
        } else {
            subtractUpkeep(unit, payObj);
        }
    }
}
Also used : BuffObj(main.entity.obj.BuffObj) Obj(main.entity.obj.Obj) PassiveAbilityObj(main.ability.PassiveAbilityObj) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Example 32 with Obj

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

the class CleaveRule method initNextTarget.

private void initNextTarget() {
    boolean first = false;
    if (clockwise == null) {
        // find targets TODO
        first = true;
    }
    // preCheck facing! always try the longest arc first, if
    clockwise = true;
    // it fails, then short one
    DIRECTION direction = DirectionMaster.getRelativeDirection(source, currentTarget);
    Obj objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
    if (objectByCoordinate instanceof Unit) {
        currentTarget = (Unit) objectByCoordinate;
    } else if (first) {
        clockwise = false;
        objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
        if (objectByCoordinate != null) {
            currentTarget = (Unit) objectByCoordinate;
        }
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) Unit(eidolons.entity.obj.unit.Unit)

Example 33 with Obj

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

the class LE_MapMaster method loadBlock.

public void loadBlock(MapBlock block) {
    if (block == null) {
        return;
    }
    Coordinates c = pickCoordinate();
    int offsetX = -CoordinatesMaster.getMinX(block.getCoordinates()) + c.x;
    int offsetY = -CoordinatesMaster.getMinY(block.getCoordinates()) + c.y;
    List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithOffset(block.getCoordinates(), offsetX, offsetY);
    // coordinates=CoordinatesMaster.getCoordinatesWithin(c.x, , c.y, y1);
    this.block = new MapBlock(getPlan().getBlocks().size(), block.getType(), getPlan().getZones().get(0), getPlan(), coordinates);
    // should add to this.block
    clearArea(coordinates);
    for (Obj obj : block.getObjects()) {
        // beware deadlock
        LevelEditor.getCurrentLevel().setInitialized(false);
        try {
            Coordinates newCoordinates = new Coordinates(obj.getCoordinates().x + offsetX, obj.getCoordinates().y + offsetY);
            obj.setCoordinates(newCoordinates);
            LevelEditor.getObjMaster().addObj(obj.getType(), obj.getCoordinates());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        } finally {
            LevelEditor.getCurrentLevel().setInitialized(true);
        }
    }
}
Also used : Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 34 with Obj

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

the class LE_ObjMaster method moveSelectedObj.

public static void moveSelectedObj() {
    Coordinates c = LE_MapMaster.pickCoordinate();
    Obj selectedObj = LevelEditor.getMouseMaster().getSelectedObj();
    int offsetX = c.x - selectedObj.getX();
    int offsetY = c.y - selectedObj.getY();
    moveObj(selectedObj.getCoordinates(), offsetX, offsetY);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates)

Example 35 with Obj

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

the class LE_TreePlanPanel method getTreeCellRendererComponent.

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value == null) {
        return null;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    value = node.getUserObject();
    if (value instanceof MapZone) {
        return getZoneComponent((MapZone) value, selected);
    }
    if (value instanceof MapBlock) {
        return getBlockComponent((MapBlock) value, selected);
    }
    if (value instanceof Obj) {
        return getObjComponent((Obj) value, selected);
    }
    // TODO add dungeon icon
    JLabel label = new JLabel(value.toString());
    label.setForeground(ColorManager.GOLDEN_WHITE);
    label.setFont(FontMaster.getFont(FONT.AVQ, 19, Font.PLAIN));
    return label;
// new DefaultTreeCellRenderer().getTreeCellRendererComponent(tree,
// value, selected, expanded, leaf, row, hasFocus)
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Obj(main.entity.obj.Obj) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6