📄 firingdisplay.java
字号:
// remove locations hidden by partial cover if(side == ToHitData.SIDE_FRONT) { if ((partialCover & LosEffects.COVER_LOWLEFT) != 0) mask[Mech.LOC_RLEG] = false; if ((partialCover & LosEffects.COVER_LOWRIGHT) != 0) mask[Mech.LOC_LLEG] = false; if ((partialCover & LosEffects.COVER_LEFT) != 0) { mask[Mech.LOC_RARM] = false; mask[Mech.LOC_RT] = false; } if ((partialCover & LosEffects.COVER_RIGHT) != 0) { mask[Mech.LOC_LARM] = false; mask[Mech.LOC_LT] = false; } } else { if ((partialCover & LosEffects.COVER_LOWLEFT) != 0) mask[Mech.LOC_LLEG] = false; if ((partialCover & LosEffects.COVER_LOWRIGHT) != 0) mask[Mech.LOC_RLEG] = false; if ((partialCover & LosEffects.COVER_LEFT) != 0) { mask[Mech.LOC_LARM] = false; mask[Mech.LOC_LT] = false; } if ((partialCover & LosEffects.COVER_RIGHT) != 0) { mask[Mech.LOC_RARM] = false; mask[Mech.LOC_RT] = false; } } if (aimingMode == IAimingModes.AIM_MODE_TARG_COMP) { // Can't target head with Clan targeting computer. mask[Mech.LOC_HEAD] = false; switch (side) { case (ToHitData.SIDE_RIGHT) : // Can't target left side when on the right // with Clan targeting computer. mask[Mech.LOC_LARM] = false; mask[Mech.LOC_LT] = false; mask[Mech.LOC_LLEG] = false; break; case (ToHitData.SIDE_LEFT) : // Can't target right side when on the left // with Clan targeting computer. mask[Mech.LOC_RARM] = false; mask[Mech.LOC_RT] = false; mask[Mech.LOC_RLEG] = false; break; } } return mask; } public void closeDialog() { if (asd != null) { aimingAt = Entity.LOC_NONE; aimingMode = IAimingModes.AIM_MODE_NONE; asd.setVisible(false); asd = null; updateTarget(); } } // Enables the radiobuttons in the dialog. public void setEnableAll(boolean enableAll) { if (asd != null && !lockedLocation) { asd.setEnableAll(enableAll); } } // All aimed shots with a targeting computer // must be at the same location. public void lockLocation(boolean lock) { if (lock) { lockedTarget = target; lockedLoc = aimingAt; setEnableAll(false); lockedLocation = true; } else { lockedTarget = null; lockedLoc = Entity.LOC_NONE; lockedLocation = false; setEnableAll(true); } } public void setPartialCover(int partialCover) { this.partialCover = partialCover; } public int getAimingAt() { return aimingAt; } public int getAimingMode() { return aimingMode; } // Returns the name of aimed location. public String getAimingLocation() { if (target != null && (aimingAt != Entity.LOC_NONE) && (aimingMode != IAimingModes.AIM_MODE_NONE)) { if (target instanceof BipedMech) { return BipedMech.LOCATION_NAMES[aimingAt]; } else if (target instanceof BipedMech){ return QuadMech.LOCATION_NAMES[aimingAt]; } else if (target instanceof GunEmplacement) { return GunEmplacement.HIT_LOCATION_NAMES[aimingAt]; } } return null; } // Sets the aiming mode, depending on the target and // the attacker. Against immobile mechs, targeting // computer aiming mode will be used if turned on. // (This is a hack, but it's the resolution suggested // by the bug submitter, and I don't think it's half // bad. public void setAimingMode() { boolean allowAim; // TC against a mech allowAim = ((target != null) && ce().hasAimModeTargComp() && target instanceof Mech); if (allowAim) { if (lockedLocation) { allowAim = ((Entity)target).equals(lockedTarget); if (allowAim) { aimingMode = IAimingModes.AIM_MODE_TARG_COMP; return; } } else { aimingMode = IAimingModes.AIM_MODE_TARG_COMP; return; } } // immobile mech or gun emplacement allowAim = (target != null && ((target.isImmobile() && target instanceof Mech) || target instanceof GunEmplacement)); if (allowAim) { aimingMode = IAimingModes.AIM_MODE_IMMOBILE; return; } aimingMode = IAimingModes.AIM_MODE_NONE; } // If in aiming mode. public boolean inAimingMode() { return aimingMode != IAimingModes.AIM_MODE_NONE; } // If a hit location is currently selected. public boolean isAimingAtLocation() { return aimingAt != Entity.LOC_NONE; } // Determines if a certain weapon may aimed at a specific // hit location. public boolean allowAimedShotWith(Mounted weapon) { WeaponType wtype = (WeaponType)weapon.getType(); boolean isWeaponInfantry = wtype.hasFlag(WeaponType.F_INFANTRY); boolean usesAmmo = wtype.getAmmoType() != AmmoType.T_NA && wtype.getAmmoType() != AmmoType.T_BA_MG && wtype.getAmmoType() != AmmoType.T_BA_SMALL_LASER && !isWeaponInfantry; Mounted ammo = usesAmmo ? weapon.getLinked() : null; AmmoType atype = ammo == null ? null : (AmmoType)ammo.getType(); // Leg and swarm attacks can't be aimed. if (wtype.getInternalName() == Infantry.LEG_ATTACK || wtype.getInternalName() == Infantry.SWARM_MEK) { return false; } switch (aimingMode) { case (IAimingModes.AIM_MODE_NONE) : return false; case (IAimingModes.AIM_MODE_IMMOBILE) : if (atype != null) { switch (atype.getAmmoType()) { case (AmmoType.T_SRM_STREAK) : case (AmmoType.T_LRM_STREAK) : case (AmmoType.T_LRM) : case (AmmoType.T_LRM_TORPEDO) : case (AmmoType.T_SRM) : case (AmmoType.T_SRM_TORPEDO) : case (AmmoType.T_MRM) : case (AmmoType.T_NARC) : case (AmmoType.T_AMS) : case (AmmoType.T_ARROW_IV) : case (AmmoType.T_LONG_TOM) : case (AmmoType.T_SNIPER) : case (AmmoType.T_THUMPER) : case (AmmoType.T_SRM_ADVANCED) : case (AmmoType.T_BA_INFERNO) : case (AmmoType.T_LRM_TORPEDO_COMBO) : case (AmmoType.T_ATM) : case (AmmoType.T_EXLRM) : case (AmmoType.T_TBOLT5) : case (AmmoType.T_TBOLT10) : case (AmmoType.T_TBOLT15) : case (AmmoType.T_TBOLT20) : case AmmoType.T_PXLRM: case AmmoType.T_HSRM: case AmmoType.T_MRM_STREAK: return false; } if (((atype.getAmmoType() == AmmoType.T_AC_LBX) || (atype.getAmmoType() == AmmoType.T_AC_LBX_THB)) && (atype.getMunitionType() == AmmoType.M_CLUSTER)) return false; } break; case (IAimingModes.AIM_MODE_TARG_COMP) : if (!wtype.hasFlag(WeaponType.F_DIRECT_FIRE)) { return false; } if ((atype != null) && ((atype.getAmmoType() == AmmoType.T_AC_LBX) || (atype.getAmmoType() == AmmoType.T_AC_LBX_THB)) && (atype.getMunitionType() == AmmoType.M_CLUSTER)) { return false; } break; } return true; } // ActionListener, listens to the button in the dialog. public void actionPerformed(ActionEvent ev) { closeDialog(); } // ItemListener, listens to the radiobuttons in the dialog. public void itemStateChanged(ItemEvent ev) { IndexedCheckbox icb = (IndexedCheckbox) ev.getSource(); aimingAt = icb.getIndex(); updateTarget(); } } /** * Determine if the listener is currently distracted. * * @return <code>true</code> if the listener is ignoring events. */ public boolean isIgnoringEvents() { return this.distracted.isIgnoringEvents(); } /** * Specify if the listener should be distracted. * * @param distract <code>true</code> if the listener should ignore events * <code>false</code> if the listener should pay attention again. * Events that occured while the listener was distracted NOT * going to be processed. */ public void setIgnoringEvents( boolean distracted ) { this.distracted.setIgnoringEvents( distracted ); } /** * Retrieve the "Done" button of this object. * * @return the <code>java.awt.Button</code> that activates this * object's "Done" action. */ public Button getDoneButton() { return butDone; } /** * Stop just ignoring events and actually stop listening to them. */ public void removeAllListeners() { client.game.removeGameListener(this); clientgui.getBoardView().removeBoardViewListener(this); clientgui.mechD.wPan.weaponList.removeItemListener(this); } /** * Have the player select a target from the entities at the given coords. * * @param pos - the <code>Coords</code> containing targets. */ private Targetable chooseTarget( Coords pos ) { boolean friendlyFire = client.game.getOptions().booleanOption("friendly_fire"); //$NON-NLS-1$ // Assume that we have *no* choice. Targetable choice = null; Enumeration choices = null; // Get the available choices, depending on friendly fire if (friendlyFire) { choices = client.game.getEntities( pos ); } else choices = client.game.getEnemyEntities(pos, ce() ); // Convert the choices into a List of targets. Vector targets = new Vector(); while ( choices.hasMoreElements() ) { choice = (Targetable) choices.nextElement(); if ( !ce().equals( choice ) ) { targets.addElement( choice ); } } // Is there a building in the hex? Building bldg = client.game.getBoard().getBuildingAt( pos ); if ( bldg != null ) { targets.addElement( new BuildingTarget(pos, client.game.getBoard(), false) ); } // Do we have a single choice? if ( targets.size() == 1 ) { // Return that choice. choice = (Targetable) targets.elementAt( 0 ); } // If we have multiple choices, display a selection dialog. else if ( targets.size() > 1 ) { String[] names = new String[ targets.size() ]; for ( int loop = 0; loop < names.length; loop++ ) { names[loop] = ( (Targetable)targets.elementAt(loop) ) .getDisplayName(); } SingleChoiceDialog choiceDialog = new SingleChoiceDialog( clientgui.frame, Messages.getString("FiringDisplay.ChooseTargetDialog.title"), //$NON-NLS-1$ Messages.getString("FiringDisplay.ChooseTargetDialog.message", new Object[]{pos.getBoardNum()}), //$NON-NLS-1$ names ); choiceDialog.setVisible(true); if ( choiceDialog.getAnswer() == true ) { choice = (Targetable) targets.elementAt ( choiceDialog.getChoice() ); } } // End have-choices // Return the chosen unit. return choice; } // End private Targetable chooseTarget( Coords )}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -