Search in sources :

Example 16 with Unit

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

the class DrawMaster method drawSpecialIcons.

private void drawSpecialIcons(Unit obj) {
    // obj.getEngagementTarget();
    /*
         * when drawing stacked objects, draw a red arrow/sword towards the ET
		 */
    Unit engageShowUnit = obj.getGame().getManager().getInfoUnit();
    if (engageShowUnit == null) {
        engageShowUnit = obj.getGame().getManager().getActiveObj();
    } else if (engageShowUnit.isBfObj()) {
        engageShowUnit = obj.getGame().getManager().getActiveObj();
    }
    Image overlay = null;
    if (engageShowUnit.getEngagementTarget() == obj) {
        overlay = STD_IMAGES.ENGAGEMENT_TARGET.getImage();
    }
    if (obj.getGame().getRules().getEngagedRule().getEngagers(engageShowUnit).contains(obj)) {
        {
            overlay = STD_IMAGES.ENGAGER.getImage();
        }
    }
    if (overlay != null) {
        BufferedImage image = ImageManager.getNewBufferedImage(getObjCompWidth(), getObjCompHeight());
        Graphics g = image.getGraphics();
        drawImage(g, overlay, 24, 24);
        BfGridComp.getOverlayMap().put(new XLine(obj.getCoordinates(), new Coordinates(getOffsetX(obj), getOffsetY(obj))), image);
    }
    if (obj.isUnconscious()) {
    // drawImage(g,
    // ImageManager.getRandomBloodOverlay(GuiManager.getObjSize()), 0,
    // 0);
    // darkening/bloody overlay! perhaps on the cell frame as well,
    // blood stains/dripping
    // drawImage(g, image, x, y);
    // black'n'white?
    }
}
Also used : XLine(main.swing.XLine) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Example 17 with Unit

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

the class DrawMasterStatic method drawDiagonalJoints.

public static void drawDiagonalJoints(int zoom, Graphics g, int offsetX, int offsetY, int w, int h, Map<Coordinates, java.util.List<Coordinates.DIRECTION>> diagonalJoints) {
    for (Coordinates c : diagonalJoints.keySet()) {
        boolean darken = false;
        Unit obj = DC_Game.game.getUnitByCoordinate(c);
        // TODO CHECK WALL
        if (obj == null) {
            obj = DC_Game.game.getUnitByCoordinate(c);
            continue;
        }
        if (!CoreEngine.isLevelEditor()) {
            if (!obj.isDetected()) {
                if (!DebugMaster.isOmnivisionOn()) // obj.getPlayerVisionStatus(false) !=
                // UNIT_TO_PLAYER_VISION.DETECTED
                {
                    continue;
                }
            }
        }
        if (obj != null) {
            darken = obj.getVisibilityLevel() != VisionEnums.VISIBILITY_LEVEL.CLEAR_SIGHT;
        }
        String prefix = darken ? "dark" : "";
        int x = w * (c.x - offsetX);
        int y = h * (c.y - offsetY);
        if (x < 0) {
            continue;
        }
        if (x > GuiManager.getBattleFieldWidth()) {
            continue;
        }
        if (y < 0) {
            continue;
        }
        if (y > GuiManager.getBattleFieldHeight()) {
            continue;
        }
        java.util.List<Coordinates.DIRECTION> list = diagonalJoints.get(c);
        for (Coordinates.DIRECTION side : list) {
            int x1 = x;
            int y1 = y;
            boolean flipped = false;
            if (side == Coordinates.DIRECTION.DOWN_LEFT) {
                y1 += h;
            } else if (side == Coordinates.DIRECTION.DOWN_RIGHT) {
                x1 += w;
                y1 += h;
                flipped = true;
            } else if (side == Coordinates.DIRECTION.UP_LEFT) {
                flipped = true;
            } else if (side == Coordinates.DIRECTION.UP_RIGHT) {
                x1 += w;
            }
            // if (list.indexOf(side) > 0) {
            // flipped = !flipped;
            // }
            // getOrCreate the rim for this side
            // add offset if necessary
            Image image = ImageManager.STD_IMAGES.WALL_CORNER_ALMOND.getPathPrefixedImage(prefix);
            if (zoom != 100) {
                image = ImageManager.getSizedVersion(image, zoom, true);
            }
            if (flipped) {
                image = ImageTransformer.flipHorizontally(ImageManager.getBufferedImage(image));
            }
            // TODO scale them!
            drawImage(g, image, x1 - image.getWidth(null) / 2, y1 - image.getHeight(null) / 2);
        }
    }
}
Also used : Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage)

Example 18 with Unit

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

the class DrawMasterStatic method drawWatchInfo.

public static void drawWatchInfo(int zoom, Graphics g) {
    DC_Obj info = DC_Game.game.getManager().getInfoObj();
    if (info instanceof Unit) {
        java.util.List<DC_Obj> watchedObjects = WatchRule.getWatchersMap().get(info);
        if (watchedObjects != null) {
            drawWatchVisuals(watchedObjects, (Unit) info, g, zoom, watchedObjects, false, true);
            drawWatchVisuals(watchedObjects, (Unit) info, g, zoom, watchedObjects, false, false);
        }
    } else {
        Unit active = DC_Game.game.getManager().getActiveObj();
        if (active.isMine()) {
            java.util.List<DC_Obj> watchedObjects = WatchRule.getWatchersMap().get(active);
            if (watchedObjects != null) {
                drawWatchVisuals(watchedObjects, active, g, zoom, watchedObjects, true, true);
                drawWatchVisuals(watchedObjects, active, g, zoom, watchedObjects, true, false);
            }
        }
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Unit(eidolons.entity.obj.unit.Unit)

Example 19 with Unit

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

the class BfMouseListener method mouseClicked.

@Override
public void mouseClicked(MouseEvent e) {
    if (checkAnimationClick(e)) {
        return;
    }
    if (checkDynamicButtonClick(e)) {
        return;
    }
    point = e.getPoint();
    cellComp = gridComp.getCompByPoint(e.getPoint());
    Point relativePoint = new Point(point.x % gridComp.getCellWidth(), point.y % gridComp.getCellHeight());
    objClicked = null;
    for (Rectangle rect : cellComp.getMouseMap().keySet()) {
        if (rect.contains(relativePoint)) {
            Object object = cellComp.getMouseMap().get(rect);
            if (object instanceof INTERACTIVE_ELEMENT) {
                INTERACTIVE_ELEMENT element = (INTERACTIVE_ELEMENT) object;
                switch(element) {
                    case STACK:
                        // if (CoreEngine.isLevelEditor())
                        objClicked = DialogMaster.objChoice("Which object?", cellComp.getObjects().toArray(new DC_Obj[cellComp.getObjects().size()]));
                        break;
                    case AP:
                        break;
                    case COUNTERS:
                        break;
                    case ITEMS:
                        Collection<? extends Obj> droppedItems = cellComp.getGame().getDroppedItemManager().getDroppedItems(cellComp.getTerrainObj());
                        break;
                    case LOCKS:
                        break;
                    case TRAPS:
                        break;
                }
            // break ;
            } else if (object instanceof Obj) {
                if (object instanceof Unit) {
                    if (objClicked != null) {
                        int index = cellComp.getObjects().indexOf(objClicked);
                        int index2 = cellComp.getObjects().indexOf(object);
                        LogMaster.log(1, objClicked + "'s " + index + " vs " + object + "'s " + index2);
                        if (index > index2) // TODO so we need to keep this always sorted...
                        {
                            continue;
                        }
                    }
                    Unit unit = (Unit) object;
                    if (unit.isOverlaying()) {
                        // corpseClicked(unit);
                        if (unit.getVisibilityLevel() == VisionEnums.VISIBILITY_LEVEL.CONCEALED) {
                            continue;
                        }
                        objClicked = unit;
                        break;
                    } else {
                        objClicked = unit;
                        continue;
                    }
                } else if (object instanceof DC_Cell) {
                    if (e.isAltDown()) {
                        objClicked = (DC_Obj) object;
                        break;
                    } else if (objClicked == null) {
                        objClicked = (DC_Obj) object;
                    }
                    // ?
                    continue;
                }
            }
        // if (objClicked == null)
        // return; // ??
        }
    }
    if (objClicked == null) {
        objClicked = cellComp.getTopObjOrCell();
    }
    if (CoreEngine.isLevelEditor()) {
        if (objClicked instanceof DC_Cell) {
            return;
        }
    }
    boolean right = SwingUtilities.isRightMouseButton(e);
    if (right) {
        objClicked.invokeRightClicked();
    // gridComp.getGame().getManager().rightClicked(objClicked);
    } else {
        gridComp.getGame().getManager().objClicked(objClicked);
    }
    boolean debugMode = gridComp.getGame().isDebugMode();
    if (debugMode) {
        gridComp.getGame().getDebugMaster().setArg(objClicked);
    }
    if (e.isAltDown()) {
        if (debugMode) {
            invokeAltClick(right);
        } else {
            new Thread(new Runnable() {

                public void run() {
                    gridComp.getGame().getMovementManager().moveTo(objClicked);
                }
            }, "moveTo thread").start();
        }
    }
    if (e.isShiftDown()) {
        invokeShiftClick(right);
    }
    if (e.isControlDown()) {
        invokeControlClick(right);
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) INTERACTIVE_ELEMENT(eidolons.swing.components.obj.drawing.DrawMaster.INTERACTIVE_ELEMENT) Unit(eidolons.entity.obj.unit.Unit)

Example 20 with Unit

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

the class DC_BattleFieldGrid method resetComponents.

@Deprecated
private void resetComponents() {
    int offsetX = getOffsetX();
    int offsetY = getOffsetY();
    LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
    for (int i = 0; i < getDisplayedCellsX(); i++) {
        for (int j = 0; j < getDisplayedCellsY(); j++) {
            int x = i + getOffsetX();
            int y = j + getOffsetY();
            Coordinates c = new Coordinates(x, y);
            List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
            List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
            // visibility preCheck!
            CellComp comp = gridComp.getCells()[x][y];
            List<BattleFieldObject> list = new ArrayList<>();
            for (BattleFieldObject obj : objects) {
                if (VisionManager.checkVisible(obj)) {
                    list.add(obj);
                }
            }
            comp.setSizeFactor(gridComp.getZoom());
            comp.setOverlayingObjects(overlayingObjects);
            if (list.size() != 0) {
            // comp.setObjects(list);
            }
            comp.refresh();
        }
    }
    comp.refresh();
}
Also used : CellComp(eidolons.swing.components.obj.CellComp) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) DequeImpl(main.system.datatypes.DequeImpl)

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