Search in sources :

Example 11 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class MetaGoalMaster method getModForOtherArgTask.

private Integer getModForOtherArgTask(Unit unit, Object metaGoalArg, ActionSequence sequence, META_GOAL_TYPE type) {
    Unit target = (Unit) unit.getGame().getObjectById((Integer) metaGoalArg);
    switch(type) {
        case PROTECT:
            if (sequence.getTask().getType() == GOAL_TYPE.ATTACK) {
                // get threat
                float threat = getThreatAnalyzer().getRelativeThreat(target.getAI(), unit);
                int mod = getThreatProtectionMod(sequence.getAi(), target);
                return (int) (threat * mod);
            }
    }
    return null;
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 12 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class DrawMaster method draw.

public void draw(CellComp cellComp, Graphics compGraphics, int zoom, boolean editorMode) {
    this.cellComp = cellComp;
    this.zoom = zoom;
    initSizes();
    Map<Rectangle, Object> mouseMap = new XLinkedMap<>();
    cellComp.setMouseMap(mouseMap);
    Unit topObj = cellComp.getTopObj();
    if (isSingleObj()) {
        Image image = cellComp.getGame().getVisionMaster().getVisibilityMaster().getDisplayImageForUnit(topObj);
        if (image != null) {
            compGraphics.drawImage(image, 0, 0, null);
            if (topObj.isWall()) {
                drawWallOverlays(topObj, compGraphics, cellComp.getCoordinates());
            }
            if (GRAPHICS_TEST_MODE) {
                DC_Obj obj = cellComp.getTopObjOrCell();
                drawCI(obj, compGraphics);
                if (FULL_GRAPHICS_TEST_MODE) {
                    compGraphics.drawString("" + obj.getOutlineType(), 0, GuiManager.getCellHeight() - 40);
                    String tooltip = cellComp.getGame().getVisionMaster().getHintMaster().getTooltip(obj);
                    if (tooltip != null) {
                        compGraphics.drawString("" + tooltip, 0, GuiManager.getCellHeight() - 20);
                    }
                    drawSightBlockInfo(cellComp, compGraphics, zoom);
                }
            }
            drawSpecialOverlays(cellComp, compGraphics, zoom);
            return;
        }
    }
    // no overlays at all? Animations at least?
    if (isFramePaintZoom()) {
        if (!isMultiObj()) {
            try {
                drawCellFrame(compGraphics);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    if (!cellComp.isTerrain()) {
        try {
            drawObjComps(compGraphics);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    } else {
        try {
            drawTerrainObj(compGraphics);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (!cellComp.isTerrain()) {
        if (topObj.isInfoSelected() || topObj.isActiveSelected()) {
            BufferedImage compOverlayImage = ImageManager.getNewBufferedImage(getCompWidth(), getCompHeight());
            drawComponentOverlays(compOverlayImage.getGraphics());
            BfGridComp.getOverlayMap().put(new XLine(new Point(topObj.getX(), topObj.getY()), new Point(5 - getObjCount() * 2, 0)), compOverlayImage);
        } else {
            drawComponentOverlays(compGraphics);
        }
    }
    drawOverlayingObjects(compGraphics, cellComp);
    // perhaps should work with Obj instead?
    if (isAnimationPaintZoom()) {
        if (cellComp.isAnimated()) {
            try {
                drawAnimations(cellComp, compGraphics);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    if (GRAPHICS_TEST_MODE) {
        drawCI(topObj, compGraphics);
    }
    if (GRAPHICS_TEST_MODE || isEditorMode() || DC_Game.game.isDebugMode()) {
        Coordinates coordinates = cellComp.getCoordinates();
        BfGridComp grid = cellComp.getGrid();
        if (grid == null) {
            grid = cellComp.getGame().getBattleField().getGrid().getGridComp();
        }
        if (coordinates.x - grid.getOffsetX() == 0) {
            drawCoordinateMarkings(coordinates.y, compGraphics, false);
        }
        if (coordinates.y - grid.getOffsetY() == 0) {
            drawCoordinateMarkings(coordinates.x, compGraphics, true);
        }
        if (cellComp.isInfoSelected()) {
            drawCoordinateMarkings(coordinates.x, compGraphics, true);
            drawCoordinateMarkings(coordinates.y, compGraphics, false);
        }
    }
    if (isSightVisualsOn()) {
    // Unit obj = cellComp.getGame().getManager().getActiveObj();
    // // if (!obj.isMine()) return ;
    // boolean extended = !obj.getSightSpectrumCoordinates(false).contains(
    // cellComp.getCoordinates());
    // if (!extended) {
    // extended = obj.getSightSpectrumCoordinates(true)
    // .contains(cellComp.getCoordinates());
    // if (!extended) {
    // return;
    // }
    // }
    // 
    // drawSightVisualsOnCell((Graphics2D) compGraphics, extended, cellComp.getObjects().size() > 0);
    // drawSightBlockInfo(cellComp, compGraphics, zoom);
    }
    drawSpecialOverlays(cellComp, compGraphics, zoom);
}
Also used : BfGridComp(eidolons.swing.components.obj.BfGridComp) XLinkedMap(main.data.XLinkedMap) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage) XLine(main.swing.XLine) DC_Obj(eidolons.entity.obj.DC_Obj)

Example 13 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class DrawMaster method drawOverlayingObjects.

private void drawOverlayingObjects(Graphics g, CellComp cellComp) {
    for (Unit obj : cellComp.getOverlayingObjects()) {
        if (!isEditorMode()) {
            if (cellComp.getGame().getVisionMaster().getVisibilityMaster().isZeroVisibility(obj)) {
                continue;
            }
        }
        DIRECTION d = obj.getDirection();
        // if (CoreEngine.isLevelEditor()) {
        if (d == null) {
        // Map<Unit, DIRECTION> map = obj.getGame().getDirectionMap().get(
        // cellComp.getCoordinates());
        // if (map != null) {
        // d = map.get(obj);
        // }
        // }
        }
        int size = overlayingSize;
        int x = MigMaster.getCenteredPosition(getObjCompWidth(), size);
        if (d != null) {
            if (d.growX == null) {
                x = MigMaster.getCenteredPosition(getObjCompWidth(), size);
            } else {
                x = (d.growX) ? getObjCompWidth() - size : 0;
            }
        }
        int y = MigMaster.getCenteredPosition(getObjCompHeight(), size);
        if (d != null) {
            if (d.growY == null) {
                y = MigMaster.getCenteredPosition(getObjCompHeight(), size);
            } else {
                y = (d.growY) ? getObjCompHeight() - size : 0;
            }
        }
        drawOverlayingObj(g, cellComp, obj, x, y, size);
    // }
    // NESW
    }
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Unit(eidolons.entity.obj.unit.Unit)

Example 14 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class DrawMaster method getStackOffsetX.

private int getStackOffsetX() {
    Unit obj = cellComp.getTopObj();
    Integer stackOffsetX;
    if (!obj.getFacing().isVertical() && obj.getFacing().isCloserToZero()) {
        stackOffsetX = getObjCount() * getXOffsetPerObj(getObjCount());
    } else {
        stackOffsetX = 0;
    }
    return stackOffsetX;
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Example 15 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class DrawMaster method drawComponentOverlays.

private void drawComponentOverlays(Graphics g) {
    if (cellComp.isAnimated()) {
        return;
    }
    Unit obj = cellComp.getTopObj();
    if (obj.isActiveSelected()) {
        drawUnitEmblem(g, obj);
        if (!isEditorMode()) {
            if (!obj.isUnconscious()) {
                drawActiveIcons(g, obj);
            }
        }
    } else if (obj.isInfoSelected()) {
        drawUnitEmblem(g, obj);
        if (!isEditorMode()) {
            if (!obj.isUnconscious()) {
                drawInfoIcons(g, obj);
            }
        }
    }
    // adjust pos for stacked! TODO
    if (!obj.isActiveSelected()) {
        if (!obj.isInfoSelected()) {
            drawPlayerEmblem(g, obj);
            drawItems(g);
        }
    }
    if (isEditorMode()) {
        return;
    }
    if (!obj.isBfObj() && cellComp.isTop(obj)) {
        drawParamsInfo(g, obj);
    }
    if (cellComp.getTopObj() == obj) {
        drawUnitEmblem(g, obj);
        // TODO stacked positioning adjusted to put facing comp outside
        if (!obj.isUnconscious()) {
            if (DrawHelper.isFacingDrawn(cellComp, obj) || (!obj.isBfObj() && DC_Game.game.isDebugMode())) {
                drawFacing(g, obj);
            }
        }
    }
    // if (!isEditorMode())
    // drawSpecialIcons(g, obj); // ?
    drawCorpses(g);
}
Also used : Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7