Search in sources :

Example 1 with DC_Cell

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

the class BfGridComp method initCellsAndMap.

private void initCellsAndMap() {
    cells = new CellComp[getCellsX()][getCellsY()];
    for (int i = 0; i < getCellsX(); i++) {
        for (int j = 0; j < getCellsY(); j++) {
            DC_Cell cellEntity = new DC_Cell(i, j, game, new Ref(), game.getDungeon());
            Coordinates coordinates = new Coordinates(i, j);
            cellEntityMap.put(coordinates, cellEntity);
            if (!CoreEngine.isLevelEditor())
                continue;
            CellComp cell = new CellComp(game, coordinates, this);
            getMap().put(coordinates, cell);
            cells[i][j] = cell;
        }
    }
}
Also used : Ref(main.entity.Ref) DC_Cell(eidolons.entity.obj.DC_Cell) Coordinates(main.game.bf.Coordinates)

Example 2 with DC_Cell

use of eidolons.entity.obj.DC_Cell 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 3 with DC_Cell

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

the class StackingRule method canBeMovedOnto.

private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
    HashMap<Coordinates, Boolean> bools = cache.get(unit);
    boolean result = false;
    if (maxSpaceTakenPercentage == 100) {
        if (bools != null) {
            if (bools.containsKey(c)) {
                return bools.get(c);
            }
        } else {
            bools = new HashMap<>();
            cache.put(unit, bools);
        }
    }
    // get all units on the cell
    DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
    for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
        if (!units.contains(u)) {
            if (!u.isAnnihilated())
                // continue; TODO why was Type necessary?
                units.addCast(!u.isDead() ? u.getType() : u);
            if (u.isWall())
                if (!u.isDead())
                    return false;
        }
    }
    // check if '1 unit per cell' is on
    if (maxSpaceTakenPercentage <= 0) {
        if (!units.isEmpty()) {
            return false;
        }
    }
    if (unit == null) {
        unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
    }
    Obj cell;
    if (!game.isSimulation()) {
        cell = game.getCellByCoordinate(c);
    } else {
        cell = new DC_Cell(c, game);
    }
    if (cell == null) {
        return false;
    }
    if (z == null) {
        if (unit instanceof Unit) {
            Unit heroObj = (Unit) unit;
            z = heroObj.getZ();
        }
    }
    // TODO ???
    if (game.isSimulation()) {
        if (units.size() > 1) {
            return false;
        }
    }
    // no passable/overlaying!
    int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
    if (c != null) {
        if (!game.isSimulation()) {
            space = cell.getIntParam(PARAMS.SPACE);
        }
    }
    int girth = 0;
    for (Entity u : units) {
        if (u == unit) {
            continue;
        }
        // }
        if (UnitAnalyzer.isWall(u)) {
            // if (!UnitAnalyzer.isFlying(unit)) {
            return false;
        // }
        }
        if (u.isDead())
            girth += u.getIntParam(PARAMS.GIRTH) / 3;
        else
            girth += u.getIntParam(PARAMS.GIRTH);
    // TODO  if (DoorMaster.isDoor((BattleFieldObject) u)) {
    // 
    // }
    // main.system.auxiliary.LogMaster.log(1, "****************** " +
    // u.getName()
    // + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
    }
    // [QUICK FIX]
    if (unit.getIntParam(PARAMS.GIRTH) == 0) {
        girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
    } else {
        girth += unit.getIntParam(PARAMS.GIRTH);
    }
    // main.system.auxiliary.LogMaster.log(1, "****************** " + space
    // + " Space vs " + girth
    // + " Girth on " + c + " for " + unit);
    space = space * maxSpaceTakenPercentage / 100;
    if (space >= girth) {
        result = true;
    } else {
        if (unit.getIntParam(PARAMS.GIRTH) > space) {
            if (units.isEmpty()) {
                result = true;
            }
        }
    }
    if (// only cache for default cases!
    maxSpaceTakenPercentage == 100) {
        bools.put(c, result);
    }
    return result;
}
Also used : Entity(main.entity.Entity) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Cell(eidolons.entity.obj.DC_Cell) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DequeImpl(main.system.datatypes.DequeImpl)

Example 4 with DC_Cell

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

the class MoveCondition method check.

@Override
public boolean check(Ref ref) {
    DC_UnitModel obj = (DC_UnitModel) ref.getSourceObj();
    DC_Cell cell = (DC_Cell) ref.getObj(KEYS.MATCH);
    return (game.getMovementManager().canMove(obj, cell));
}
Also used : DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) DC_Cell(eidolons.entity.obj.DC_Cell)

Example 5 with DC_Cell

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

the class GridCell method act.

@Override
public void act(float delta) {
    if (gridX == 0)
        if (gridY == 0)
            gridX = 0;
    if (!SuperActor.isCullingOff())
        if (!DungeonScreen.getInstance().controller.isWithinCamera((this))) {
            return;
        }
    super.act(delta);
    if (DC_Game.game.isDebugMode()) {
        if (!cordsText.isVisible()) {
            cordsText.setVisible(true);
        }
        if (GammaMaster.DEBUG_MODE) {
            DC_Cell cell = DC_Game.game.getCellByCoordinate(new Coordinates(gridX, gridY));
            cordsText.setText(getGridX() + ":" + getGridY() + "\n gamma=" + DC_Game.game.getVisionMaster().getGammaMaster().getGammaForCell(getGridX(), getGridY()) + "\n illumination=" + cell.getIntParam(PARAMS.ILLUMINATION));
            cordsText.setPosition(0, getHeight() / 2 - cordsText.getHeight() / 2);
        } else {
            cordsText = new Label(getGridX() + ":" + getGridY(), StyleHolder.getDefaultLabelStyle());
            cordsText.setPosition(getWidth() / 2 - cordsText.getWidth() / 2, getHeight() / 2 - cordsText.getHeight() / 2);
        }
    } else {
        if (cordsText.isVisible()) {
            cordsText.setVisible(false);
        }
    }
}
Also used : DC_Cell(eidolons.entity.obj.DC_Cell) Coordinates(main.game.bf.Coordinates) Label(com.badlogic.gdx.scenes.scene2d.ui.Label)

Aggregations

DC_Cell (eidolons.entity.obj.DC_Cell)23 Coordinates (main.game.bf.Coordinates)11 Unit (eidolons.entity.obj.unit.Unit)10 DC_Obj (eidolons.entity.obj.DC_Obj)6 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)5 ArrayList (java.util.ArrayList)5 Obj (main.entity.obj.Obj)5 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)3 Ref (main.entity.Ref)3 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 UNIT_VISION (main.content.enums.rules.VisionEnums.UNIT_VISION)2 DIRECTION (main.game.bf.Coordinates.DIRECTION)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 SelfMoveEffect (eidolons.ability.effects.oneshot.move.SelfMoveEffect)1 DC_QuickItemAction (eidolons.entity.active.DC_QuickItemAction)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1