📄 firingdisplay.java
字号:
} } if (ash.allowAimedShotWith(mounted) && ash.inAimingMode() && ash.isAimingAtLocation()) { waa.setAimedLocation(ash.getAimingAt()); waa.setAimingMode(ash.getAimingMode()); if (ash.getAimingMode() == IAimingModes.AIM_MODE_TARG_COMP) { ash.lockLocation(true); } } else { waa.setAimedLocation(Entity.LOC_NONE); waa.setAimingMode(IAimingModes.AIM_MODE_NONE); } // add the attack to our temporary queue attacks.addElement(waa); // and add it into the game, temporarily client.game.addAction(waa); clientgui.bv.addAttack(waa); clientgui.bv.repaint(100); clientgui.minimap.drawMap(); // set the weapon as used mounted.setUsedThisRound(true); // find the next available weapon int nextWeapon = ce().getNextWeapon(weaponNum); // check; if there are no ready weapons, you're done. if (nextWeapon == -1 && GUIPreferences.getInstance().getAutoEndFiring()) { ready(); return; } // otherwise, display firing info for the next weapon clientgui.mechD.wPan.displayMech(ce()); clientgui.mechD.wPan.selectWeapon(nextWeapon); updateTarget(); } /** * Skips to the next weapon */ private void nextWeapon() { int nextWeapon = ce().getNextWeapon(clientgui.mechD.wPan.getSelectedWeaponNum()); // if there's no next weapon, forget about it if(nextWeapon == -1) { return; } clientgui.mechD.wPan.displayMech(ce()); clientgui.mechD.wPan.selectWeapon(nextWeapon); updateTarget(); } /** * The entity spends the rest of its turn finding a club */ private void findClub() { if (ce() == null) { return; } // comfirm this action String title = Messages.getString("FiringDisplay.FindClubDialog.title"); //$NON-NLS-1$ String body = Messages.getString("FiringDisplay.FindClubDialog.message"); //$NON-NLS-1$ if (!clientgui.doYesNoDialog(title, body)) { return; } attacks.removeAllElements(); attacks.addElement(new FindClubAction(cen)); ready(); } /** * The entity spends the rest of its turn spotting */ private void doSpot() { if (ce() == null) { return; } if (ce().isINarcedWith( INarcPod.HAYWIRE )) { String title = Messages.getString("FiringDisplay.CantSpotDialog.title"); //$NON-NLS-1$ String body = Messages.getString("FiringDisplay.CantSpotDialog.message"); //$NON-NLS-1$ clientgui.doAlertDialog(title, body); return; } // comfirm this action String title = Messages.getString("FiringDisplay.SpotForInderectDialog.title"); //$NON-NLS-1$ String body = Messages.getString("FiringDisplay.SpotForInderectDialog.message"); //$NON-NLS-1$ if (!clientgui.doYesNoDialog(title, body)) { return; } attacks.removeAllElements(); attacks.addElement(new SpotAction(cen)); ready(); } /** * Removes all current fire */ private void clearAttacks() { // We may not have an entity selected yet (race condition). if (ce() == null) { return; } // remove attacks, set weapons available again Enumeration i = attacks.elements(); while ( i.hasMoreElements() ) { Object o = i.nextElement(); if (o instanceof WeaponAttackAction) { WeaponAttackAction waa = (WeaponAttackAction)o; ce().getEquipment(waa.getWeaponId()).setUsedThisRound(false); } } attacks.removeAllElements(); // remove temporary attacks from game & board removeTempAttacks(); // restore any other movement to default ce().setSecondaryFacing(ce().getFacing()); ce().setArmsFlipped(false); ash.lockLocation(false); } /** * Removes temp attacks from the game and board */ private void removeTempAttacks() { // remove temporary attacks from game & board client.game.removeActionsFor(cen); clientgui.bv.removeAttacksFor(cen); clientgui.bv.repaint(100); } /** * removes the last action */ private void removeLastFiring() { Object o = attacks.lastElement(); if (o instanceof WeaponAttackAction) { WeaponAttackAction waa = (WeaponAttackAction)o; ce().getEquipment(waa.getWeaponId()).setUsedThisRound(false); attacks.removeElement(o); clientgui.mechD.wPan.displayMech(ce()); client.game.removeAction(o); clientgui.bv.refreshAttacks(); clientgui.bv.repaint(100); clientgui.minimap.drawMap(); } } /** * Refeshes all displays. */ private void refreshAll() { if (ce() == null) { return; } clientgui.bv.redrawEntity(ce()); clientgui.mechD.displayEntity(ce()); clientgui.mechD.showPanel("weapons"); //$NON-NLS-1$ clientgui.mechD.wPan.selectWeapon(ce().getFirstWeapon()); updateTarget(); } /** * Targets something */ void target(Targetable t) { this.target = t; ash.setAimingMode(); updateTarget(); ash.showDialog(); } /** * Targets something */ protected void updateTarget() { setFireEnabled(false); // make sure we're showing the current entity in the mech display if (ce() != null && !ce().equals(clientgui.mechD.getCurrentEntity())) { clientgui.mechD.displayEntity(ce()); } // update target panel final int weaponId = clientgui.mechD.wPan.getSelectedWeaponNum(); if (target != null && weaponId != -1 && ce() != null && !ce().usedTag()) { ToHitData toHit; if (ash.inAimingMode()) { Mounted weapon = ce().getEquipment(weaponId); boolean aiming = ash.isAimingAtLocation() && ash.allowAimedShotWith(weapon); ash.setEnableAll(aiming); if (aiming) { toHit = WeaponAttackAction.toHit(client.game, cen, target, weaponId, ash.getAimingAt(), ash.getAimingMode()); clientgui.mechD.wPan.wTargetR.setText(target.getDisplayName() + " (" + ash.getAimingLocation() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } else { toHit = WeaponAttackAction.toHit(client.game, cen, target, weaponId, Entity.LOC_NONE, IAimingModes.AIM_MODE_NONE); clientgui.mechD.wPan.wTargetR.setText(target.getDisplayName()); } ash.setPartialCover(toHit.getCover()); } else { toHit = WeaponAttackAction.toHit(client.game, cen, target, weaponId, Entity.LOC_NONE, IAimingModes.AIM_MODE_NONE); clientgui.mechD.wPan.wTargetR.setText(target.getDisplayName()); } clientgui.mechD.wPan.wRangeR.setText("" + ce().getPosition().distance(target.getPosition())); //$NON-NLS-1$ Mounted m = ce().getEquipment(weaponId); if (m.isUsedThisRound()) { clientgui.mechD.wPan.wToHitR.setText(Messages.getString("FiringDisplay.alreadyFired")); //$NON-NLS-1$ setFireEnabled(false); } else if (m.getType().hasFlag(WeaponType.F_AUTO_TARGET)) { clientgui.mechD.wPan.wToHitR.setText(Messages.getString("FiringDisplay.autoFiringWeapon")); //$NON-NLS-1$ setFireEnabled(false); } else if (toHit.getValue() == ToHitData.IMPOSSIBLE) { clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString()); setFireEnabled(false); } else if (toHit.getValue() == ToHitData.AUTOMATIC_FAIL) { clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString()); setFireEnabled(true); } else { clientgui.mechD.wPan.wToHitR.setText(toHit.getValueAsString() + " (" + Compute.oddsAbove(toHit.getValue()) + "%)"); //$NON-NLS-1$ //$NON-NLS-2$ setFireEnabled(true); } clientgui.mechD.wPan.toHitText.setText(toHit.getDesc()); setSkipEnabled(true); } else { clientgui.mechD.wPan.wTargetR.setText("---"); //$NON-NLS-1$ clientgui.mechD.wPan.wRangeR.setText("---"); //$NON-NLS-1$ clientgui.mechD.wPan.wToHitR.setText("---"); //$NON-NLS-1$ clientgui.mechD.wPan.toHitText.setText(""); //$NON-NLS-1$ } updateSearchlight(); } /** * Torso twist in the proper direction. */ private void torsoTwist(Coords target) { int direction = ce().getFacing(); if ( null != target ) direction = ce().clipSecondaryFacing(ce().getPosition().direction(target)); if (direction != ce().getSecondaryFacing()) { clearAttacks(); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } } /** * Torso twist to the left or right * @param target An <code>int</code> specifying wether we're twisting left or right, * 0 if we're twisting to the left, 1 if to the right. */ private void torsoTwist(int target) { int direction = ce().getSecondaryFacing(); if (target == 0) { clearAttacks(); direction = ce().clipSecondaryFacing((direction+5)%6); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } else if (target == 1) { clearAttacks(); direction = ce().clipSecondaryFacing((direction+7)%6); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } } /** * Returns the current entity. */ private Entity ce() { return client.game.getEntity(cen); } // // BoardListener // public void hexMoused(BoardViewEvent b) { // Are we ignoring events? if ( this.isIgnoringEvents() ) { return; } // ignore buttons other than 1 if (!client.isMyTurn() || (b.getModifiers() & MouseEvent.BUTTON1_MASK) == 0) { return; } // control pressed means a line of sight check. // added ALT_MASK by kenn if ((b.getModifiers() & InputEvent.CTRL_MASK) != 0 || (b.getModifiers() & InputEvent.ALT_MASK) != 0) { return; } // check for shifty goodness if (shiftheld != ((b.getModifiers() & MouseEvent.SHIFT_MASK) != 0)) { shiftheld = (b.getModifiers() & MouseEvent.SHIFT_MASK) != 0; } if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) { if (shiftheld || twisting) { updateFlipArms(false); torsoTwist(b.getCoords()); } clientgui.getBoardView().cursor(b.getCoords()); } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { twisting = false; clientgui.getBoardView().select(b.getCoords()); } } public void hexSelected(BoardViewEvent b) { // Are we ignoring events? if ( this.isIgnoringEvents() ) { return; } if (client.isMyTurn() && b.getCoords() != null && ce() != null && !b.getCoords().equals(ce().getPosition())) { // HACK : sometimes we don't show the target choice window Targetable targ = null; if (this.showTargetChoice) targ = this.chooseTarget( b.getCoords() ); if (shiftheld) { updateFlipArms(false); torsoTwist(b.getCoords()); } else if ( targ != null ) { target( targ ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -