game.getBoard().getCenter() : closest.getPosition(); int desiredFacing = (toFace.direction(movingUnit.getPosition()) + 3) % 6; int currentFacing = path.getFinalFacing(); int facingDiff;
protected void setDamageDirection(EntityState targetState, Coords shooterCoords) { int fromDirection = targetState.getPosition().direction(shooterCoords); setDamageDirection(((fromDirection - targetState.getFacing()) + 6) % 6); }
private void connectHexes(Coords src, Coords dest, int roadStyle) { if (board.contains(src)) { IHex hex = board.getHex(src); ITerrain t = hex.getTerrain(Terrains.ROAD); if (t == null) { t = hex.getTerrain(Terrains.BRIDGE); } if (t == null) { addRoad(hex, src.direction(dest), roadStyle); } else { t.setExit(src.direction(dest), true); } } }
int dir = currStep.direction(dest); findSimplePathTo(dest, MoveStepType.FORWARDS, currStep.direction(dest), facing); break; case 1: findSimplePathTo(dest, MoveStepType.LATERAL_RIGHT, currStep.direction(dest), facing); break; case 2: findSimplePathTo(dest, MoveStepType.LATERAL_LEFT_BACKWARDS, currStep.direction(dest), facing); break; case 3: findSimplePathTo(dest, MoveStepType.BACKWARDS, currStep.direction(dest), facing); break; case 4: findSimplePathTo(dest, MoveStepType.LATERAL_RIGHT_BACKWARDS, currStep.direction(dest), facing); break; case 5: findSimplePathTo(dest, MoveStepType.LATERAL_LEFT, currStep.direction(dest), facing); break;
int centerDirection = src.direction(dest); if (split) {
private int calcAttackDirection() { return getTargetState().getPosition().direction(getShooterState().getPosition()); }
private int getFacingDiff(final MovePath first) { if (first.isJumping()) { return 0; } if (first.getFinalCoords().equals(destination)) { return 0; } int firstFacing = Math.abs(((first.getFinalCoords().direction(destination) + (backward ? 3 : 0)) % 6) - first.getFinalFacing()); if (firstFacing > 3) { firstFacing = 6 - firstFacing; } if (first.canShift()) { firstFacing = Math.max(0, firstFacing - 1); } if ((first.getFinalCoords().degree(destination) % 60) != 0) { firstFacing++; } return firstFacing; } }
/** * Find the shortest path to the destination <code>Coords</code> by hex * count. This right choice <em>only</em> when making a simple move like a * straight line or one with a single turn. * * @param dest the destination <code>Coords</code> of the move. * @param type the type of movment step required. */ private void lazyPathfinder(final Coords dest, final MoveStepType type) { MoveStepType step = MoveStepType.FORWARDS; if (type == MoveStepType.BACKWARDS) { step = MoveStepType.BACKWARDS; } Coords subDest = dest; if (!dest.equals(getFinalCoords())) { subDest = dest.translated(dest.direction(getFinalCoords())); } while (!getFinalCoords().equals(subDest)) { // adjust facing rotatePathfinder((getFinalCoords().direction(subDest) + (step == MoveStepType.BACKWARDS ? 3 : 0)) % 6, false); // step forwards addStep(step); } rotatePathfinder((getFinalCoords().direction(dest) + (step == MoveStepType.BACKWARDS ? 3 : 0)) % 6, false); if (!dest.equals(getFinalCoords())) { addStep(type); } }
int destDir = mp.getFinalCoords().direction(dest);
private Coords extendRoad(Coords coords, int nextDirection, int roadStyle) { Coords next = selectNextGrid(nextDirection, coords); if (board.contains(next) && hexNeedsBridge(board.getHex(next))) { if (nextDirection == E || nextDirection == W) { nextDirection = coords.direction(next); } Coords end = tryToBuildBridge(coords, nextDirection); return end; } connectHexes(coords, next, roadStyle); connectHexes(next, coords, roadStyle); return next; }
/** * Returns new MovePath for the currently selected movement type */ private void currentMove(Coords dest) { if (dest != null) { if (gear == GEAR_TURN) { cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), false); } else if (gear == GEAR_LAND || gear == GEAR_JUMP) { cmd.findPathTo(dest, MoveStepType.FORWARDS); } else if (gear == GEAR_BACKUP) { cmd.findPathTo(dest, MoveStepType.BACKWARDS); } else if (gear == GEAR_CHARGE) { cmd.findPathTo(dest, MoveStepType.CHARGE); } else if (gear == GEAR_DFA) { cmd.findPathTo(dest, MoveStepType.DFA); } else if (gear == GEAR_SWIM) { cmd.findPathTo(dest, MoveStepType.SWIM); } } }
/** * Torso twist in the proper direction. */ void torsoTwist(Coords twistTarget) { int direction = ce().getFacing(); if (twistTarget != null) { direction = ce().clipSecondaryFacing( ce().getPosition().direction(twistTarget)); } if (direction != ce().getSecondaryFacing()) { clearAttacks(); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } }
/** * Torso twist in the proper direction. */ void torsoTwist(Coords cTarget) { int direction = ce().getFacing(); if (null != cTarget) { direction = ce().clipSecondaryFacing( ce().getPosition().direction(cTarget)); } if (direction != ce().getSecondaryFacing()) { clearAttacks(); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } }
&& lastPos.direction(curPos) % 3 != curFacing % 3 && !(isUsingManAce() && (overallMoveType == EntityMovementType.MOVE_WALK || overallMoveType == EntityMovementType.MOVE_VTOL_WALK))) {
final IHex destHex = game.getBoard().getHex(dest); final ArrayList<Coords> intervening = Coords.intervening(src, dest); final int direction = src.direction(dest);
int dir = current.direction(c);
final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHex(dest); final int src2destDir = src.direction(dest); final int dest2srcDir = (src2destDir + 3) % 6; boolean result = false;
.getBoard().getHeight() / 2); nDir = cDeploy.direction(pointing_to);