Search in sources :

Example 6 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class BehaviorMaster method getAction.

private Action getAction(GOAL_TYPE type, UnitAI ai) {
    String action = null;
    Integer target = null;
    // doesn't the group have standing orders as a whole?..
    Unit unit = ai.getUnit();
    Ref ref = new Ref(unit);
    GroupAI group = ai.getGroup();
    // checkBehaviorChange(group); where does that happen?
    switch(type) {
        case AMBUSH:
            break;
        case STALK:
            break;
        case STAND_GUARD:
        case PATROL:
            PatrolMaster.getPatrolAction(ai);
        // having already turned on the Mode
        case SEARCH:
        case WANDER:
            if (ai.isLeader()) {
                Boolean change = WanderAi.checkWanderDirectionChange(group, type);
                if (change == null) {
                    action = getIdleAction(ai, type);
                    change = true;
                }
                // maybe go meet leader if blocked... or something like it
                if (change) {
                    group.getWanderStepCoordinateStack().push(group.getLeader().getCoordinates());
                    WanderAi.changeGroupMoveDirection(group, type);
                }
            }
            boolean wait = false;
            // ActionSequenceConstructor.getSequence(targetAction, task)
            Coordinates targetCoordinates = WanderAi.getCoordinates(type, ai);
            if (targetCoordinates == null) {
                wait = true;
            // if (!recursion)
            // return null;
            // recursion = true;
            // return getAction(type, ai);
            } else {
                action = STD_ACTIONS.Move.name();
                // if (!unit.getAction(action).canBeActivated()) {
                // }
                ActionPath path = getPathBuilder().init(new ListMaster<DC_ActiveObj>().getList(unit.getAction(action)), new Action(unit.getAction(action), new Ref(unit))).getPathByPriority(new ListMaster<Coordinates>().getList(targetCoordinates));
                if (path == null) {
                    // TODO preCheck if path
                    ai.setPathBlocked(true);
                // appropriate
                } else {
                    ai.setPathBlocked(false);
                    return path.getActions().get(0);
                }
            }
            if (wait) {
                action = getIdleAction(ai, type);
            } else {
            // if (change) {
            // targetCoordinates = WanderMaster.getCoordinates(type,
            // ai);
            // }
            // return path.getActions().getOrCreate(0);
            }
    }
    DC_ActiveObj active = unit.getAction(action);
    ref.setTarget(target);
    recursion = false;
    return new Action(active, ref);
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) Coordinates(main.game.bf.Coordinates) ActionPath(eidolons.game.battlecraft.ai.tools.path.ActionPath) ListMaster(main.system.auxiliary.data.ListMaster) Unit(eidolons.entity.obj.unit.Unit) Ref(main.entity.Ref) GroupAI(eidolons.game.battlecraft.ai.GroupAI) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj)

Example 7 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class ActionManager method checkWaitForBlockingAlly.

private Integer checkWaitForBlockingAlly() {
    Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(getUnit().getFacing().getDirection());
    Obj obj = getUnit().getGame().getObjectVisibleByCoordinate(c);
    if (obj instanceof Unit) {
        if (((Unit) obj).canActNow()) // if (!((DC_HeroObj) obj).checkStatus(STATUS.WAITING))
        {
            return obj.getId();
        }
    }
    return null;
}
Also used : Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 8 with Coordinates

use of main.game.bf.Coordinates 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 9 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class DrawMaster method drawOverlayingObj.

private void drawOverlayingObj(Graphics g, CellComp cellComp, Unit obj, int x, int y, int size) {
    Image img = cellComp.getGame().getVisionMaster().getVisibilityMaster().getDisplayImageForUnit(obj);
    if (img != null) {
        img = ImageManager.getSizedVersion(img, size);
    } else {
        if (obj.checkProperty(PROPS.BF_OBJECT_SIZE, BfObjEnums.BF_OBJECT_SIZE.LARGE.name())) {
            size += size / 2;
        } else if (obj.checkProperty(PROPS.BF_OBJECT_SIZE, BfObjEnums.BF_OBJECT_SIZE.HUGE.name())) {
            size += size;
        } else if (obj.checkProperty(G_PROPS.BF_OBJECT_TAGS, BfObjEnums.BF_OBJECT_TAGS.LARGE.name())) {
            size += size;
        } else if (obj.checkProperty(G_PROPS.BF_OBJECT_TAGS, BfObjEnums.BF_OBJECT_TAGS.HUGE.name())) {
            size += size;
        }
        int h = size;
        int w = size;
        // if (obj.getIntParam(PARAMS.HEIGHT) > 0) {
        // h = obj.getIntParam(PARAMS.HEIGHT) * zoom / 100;
        // }
        // if (obj.getIntParam(PARAMS.WIDTH) > 0) {
        // w = obj.getIntParam(PARAMS.WIDTH) * zoom / 100;
        // }
        Dimension d = new Dimension(w, h);
        img = ImageManager.getSizedIcon(obj.getImagePath(), d).getImage();
    }
    drawImage(g, img, x, y);
    Rectangle rect = new Rectangle(x, y, size, size);
    cellComp.getMouseMap().put(rect, obj);
    if (obj.isInfoSelected()) {
        BfGridComp.setStackedHighlightRelativeCoordinates(new Coordinates(true, x, y), true);
    }
}
Also used : Coordinates(main.game.bf.Coordinates) BufferedImage(java.awt.image.BufferedImage)

Example 10 with Coordinates

use of main.game.bf.Coordinates 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)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5