📄 movementdisplay.java
字号:
Entity next = client.game.getNextEntity(client.game.getTurnIndex()); if (IGame.PHASE_MOVEMENT == client.game.getPhase() && null != next && null != ce && next.getOwnerId() != ce.getOwnerId()) { clientgui.setDisplayVisible(false); } cen = Entity.NONE; clientgui.getBoardView().select(null); clientgui.getBoardView().highlight(null); clientgui.getBoardView().cursor(null); clientgui.bv.clearMovementData(); } /** * Disables all buttons in the interface */ private void disableButtons() { setWalkEnabled(false); setJumpEnabled(false); setBackUpEnabled(false); setTurnEnabled(false); setFleeEnabled(false); setEjectEnabled(false); setUnjamEnabled(false); setSearchlightEnabled(false, false); setGetUpEnabled(false); setGoProneEnabled(false); setChargeEnabled(false); setDFAEnabled(false); setNextEnabled(false); butMore.setEnabled(false); butDone.setEnabled(false); setLoadEnabled(false); setUnloadEnabled(false); setClearEnabled(false); setHullDownEnabled(false); setSwimEnabled(false); } /** * Clears out the curently selected movement data and * resets it. */ private void clearAllMoves() { final Entity ce = ce(); //switch back from swimming to normal mode. if (ce.getMovementMode() == IEntityMovementMode.BIPED_SWIM) ce.setMovementMode(IEntityMovementMode.BIPED); else if (ce.getMovementMode() == IEntityMovementMode.QUAD_SWIM) ce.setMovementMode(IEntityMovementMode.QUAD); // clear board cursors clientgui.getBoardView().select(null); clientgui.getBoardView().cursor(null); // create new current and considered paths cmd = new MovePath(client.game, ce); // set to "walk," or the equivalent gear = MovementDisplay.GEAR_LAND; // update some GUI elements clientgui.bv.clearMovementData(); butDone.setText(Messages.getString("MovementDisplay.Done")); //$NON-NLS-1$ updateProneButtons(); updateRACButton(); updateSearchlightButton(); updateElevationButtons(); // We may not have an entity selected yet (race condition). if (ce != null) { loadedUnits = ce.getLoadedUnits(); } else { // The variable, loadedUnits, can not be null. loadedUnits = new Vector(); } updateLoadButtons(); updateElevationButtons(); } private void removeLastStep() { cmd.removeLastStep(); if (cmd.length() == 0) { clearAllMoves(); } else { clientgui.bv.drawMovementData(cmd); // Set the button's label to "Done" // if the entire move is impossible. MovePath possible = (MovePath) cmd.clone(); possible.clipToPossible(); if (possible.length() == 0) { butDone.setText(Messages.getString("MovementDisplay.Done")); //$NON-NLS-1$ } } } /** * Sends a data packet indicating the chosen movement. */ private synchronized void moveTo(MovePath md) { md.clipToPossible(); if (md.length() == 0 && GUIPreferences.getInstance().getNagForNoAction()) { //Hmm....no movement steps, comfirm this action String title = Messages.getString("MovementDisplay.ConfirmNoMoveDlg.title"); //$NON-NLS-1$ String body = Messages.getString("MovementDisplay.ConfirmNoMoveDlg.message"); //$NON-NLS-1$ ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body); if (!response.getShowAgain()) { GUIPreferences.getInstance().setNagForNoAction(false); } if (!response.getAnswer()) { return; } } if (md != null) { if (md.hasActiveMASC() && GUIPreferences.getInstance().getNagForMASC()) { //pop up are you sure dialog Mech m = (Mech) ce(); ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), //$NON-NLS-1$ Messages.getString("MovementDisplay.ConfirmMoveRoll", new Object[]{new Integer(m.getMASCTarget())}), //$NON-NLS-1$ true); nag.setVisible(true); if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { GUIPreferences.getInstance().setNagForMASC(false); } } else { return; } } String check = doPSRCheck(md); if (check.length() > 0 && GUIPreferences.getInstance().getNagForPSR()) { ConfirmDialog nag = new ConfirmDialog(clientgui.frame, Messages.getString("MovementDisplay.areYouSure"), //$NON-NLS-1$ Messages.getString("MovementDisplay.ConfirmPilotingRoll") + //$NON-NLS-1$ check, true); nag.setVisible(true); if (nag.getAnswer()) { // do they want to be bothered again? if (!nag.getShowAgain()) { GUIPreferences.getInstance().setNagForPSR(false); } } else { return; } } } disableButtons(); clientgui.bv.clearMovementData(); if (ce().hasUMU()) { client.sendUpdateEntity(ce()); } client.moveEntity(cen, md); } private String addNag(PilotingRollData rollTarget) { return Messages.getString("MovementDisplay.addNag", new Object[]{rollTarget.getValueAsString(), rollTarget.getDesc()});//$NON-NLS-1$ } /** * Checks to see if piloting skill rolls are needed for the * currently selected movement. This code is basically a * simplified version of Server.processMovement(), except * that it just reads information (no writing). Note that * MovePath.clipToPossible() is called though, which changes the * md object. */ private String doPSRCheck(MovePath md) { StringBuffer nagReport = new StringBuffer(); final Entity entity = ce(); // okay, proceed with movement calculations Coords lastPos = entity.getPosition(); Coords curPos = entity.getPosition(); int curFacing = entity.getFacing(); int distance = 0; int moveType = IEntityMovementType.MOVE_NONE; int overallMoveType = IEntityMovementType.MOVE_NONE; boolean firstStep; int prevFacing = curFacing; IHex prevHex = null; final boolean isInfantry = (entity instanceof Infantry); PilotingRollData rollTarget; // Compile the move md.clipToPossible(); overallMoveType = md.getLastStepMovementType(); // iterate through steps firstStep = true; /* Bug 754610: Revert fix for bug 702735. */ MoveStep prevStep = null; for (final Enumeration i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = (MoveStep) i.nextElement(); boolean isPavementStep = step.isPavementStep(); // stop for illegal movement if (step.getMovementType() == IEntityMovementType.MOVE_ILLEGAL) { break; } // check piloting skill for getting up rollTarget = entity.checkGetUp(step); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } // set most step parameters moveType = step.getMovementType(); distance = step.getDistance(); // set last step parameters curPos = step.getPosition(); curFacing = step.getFacing(); final IHex curHex = client.game.getBoard().getHex(curPos); // Check for skid. rollTarget = entity.checkSkid(moveType, prevHex, overallMoveType, prevStep, prevFacing, curFacing, lastPos, curPos, isInfantry, distance); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { // Have an entity-meaningful PSR message. nagReport.append(addNag(rollTarget)); } // check if we've moved into rubble rollTarget = entity.checkRubbleMove(step, curHex, lastPos, curPos); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } // check for crossing ice if (curHex.containsTerrain(Terrains.ICE) && curHex.containsTerrain(Terrains.WATER) && !(curPos.equals(lastPos)) && step.getElevation() == 0 && moveType != IEntityMovementType.MOVE_JUMP) { nagReport.append(Messages.getString("MovementDisplay.IceMoving")); } // check if we've moved into water rollTarget = entity.checkWaterMove(step, curHex, lastPos, curPos, isPavementStep); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } // check for non-mech entering a fire if (curHex.containsTerrain(Terrains.FIRE) && !(entity instanceof Mech) && step.getElevation() <= 1 && moveType != IEntityMovementType.MOVE_JUMP && !(curPos.equals(lastPos))) { nagReport.append(Messages.getString("MovementDisplay.FireMoving", new Object[]{new Integer(8)})); } // check for magma int level = curHex.terrainLevel(Terrains.MAGMA); if (level == 1 && step.getElevation() == 0 && moveType != IEntityMovementType.MOVE_JUMP && !(curPos.equals(lastPos))) { nagReport.append(Messages.getString("MovementDisplay.MagmaCrustMoving")); } else if (level == 2 && entity.getElevation() == 0 && moveType != IEntityMovementType.MOVE_JUMP && entity.getMovementMode() != IEntityMovementMode.HOVER && !(curPos.equals(lastPos))) { nagReport.append(Messages.getString("MovementDisplay.MagmaLiquidMoving")); } if (entity instanceof VTOL) { rollTarget = ((VTOL) entity).checkSideSlip(moveType, prevHex, overallMoveType, prevStep, prevFacing, curFacing, lastPos, curPos, distance); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } } // check if we've moved into swamp rollTarget = entity.checkSwampMove(step, curHex, lastPos, curPos, isPavementStep); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } // check if we used more MPs than the Mech/Vehicle would have in normal gravity if (!i.hasMoreElements() && !firstStep) { if ((entity instanceof Mech) || (entity instanceof VTOL)) { if ((step.getMovementType() == IEntityMovementType.MOVE_WALK) || (step.getMovementType() == IEntityMovementType.MOVE_VTOL_WALK) || (step.getMovementType() == IEntityMovementType.MOVE_RUN) || (step.getMovementType() == IEntityMovementType.MOVE_VTOL_RUN)) { if (step.getMpUsed() > entity.getRunMP(false)) { rollTarget = entity.checkMovedTooFast(step); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } } } else if (step.getMovementType() == IEntityMovementType.MOVE_JUMP) { if (step.getMpUsed() > entity.getOriginalJumpMP()) { rollTarget = entity.checkMovedTooFast(step); if (rollTarget.getValue() != TargetRoll.CHECK_FALSE) { nagReport.append(addNag(rollTarget)); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -