⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 firingdisplay.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }    }        /**     * Does turn start stuff     */    private void beginMyTurn() {        target = null;        selectEntity(client.getFirstEntityNum());        if (!clientgui.bv.isMovingUnits()) {            clientgui.setDisplayVisible(true);        }        // There's special processing for triggering AP Pods.        if ( client.game.getTurn() instanceof GameTurn.TriggerAPPodTurn &&             null != ce() ) {            disableButtons();            TriggerAPPodDialog dialog = new TriggerAPPodDialog                ( clientgui.getFrame(), ce() );            dialog.setVisible(true);            attacks.removeAllElements();            Enumeration actions = dialog.getActions();            while ( actions.hasMoreElements() ) {                attacks.addElement( actions.nextElement() );            }            ready();        } else {            setNextEnabled(true);            butDone.setEnabled(true);            butMore.setEnabled(true);            setFireModeEnabled(true); // Fire Mode - Setting Fire Mode to true, currently doesn't detect if weapon has a special Fire Mode or not- Rasia        client.setDisplayVisible(true);            clientgui.getBoardView().select(null);        }    }        /**     * Does end turn stuff.     */    private void endMyTurn() {        // end my turn, then.        Entity next = client.game.getNextEntity( client.game.getTurnIndex() );        if ( IGame.PHASE_FIRING == client.game.getPhase()             && null != next             && null != ce()             && next.getOwnerId() != ce().getOwnerId() ) {            clientgui.setDisplayVisible(false);        }        cen = Entity.NONE;        target(null);        clientgui.getBoardView().select(null);        clientgui.getBoardView().highlight(null);        clientgui.getBoardView().cursor(null);        clientgui.bv.clearMovementData();        disableButtons();                clearVisibleTargets();    }        /**     * Disables all buttons in the interface     */    private void disableButtons() {        setFireEnabled(false);        setSkipEnabled(false);        setTwistEnabled(false);        setSpotEnabled(false);        setFindClubEnabled(false);        butMore.setEnabled(false);        setNextEnabled(false);        butDone.setEnabled(false);        setNextTargetEnabled(false);        setFlipArmsEnabled(false);        setFireModeEnabled(false); // Fire Mode - Handlng of Fire Mode Button - Rasia    }       /**    * Fire Mode - Adds a Fire Mode Change to the current Attack Action    */    private void changeMode() {        int wn = clientgui.mechD.wPan.getSelectedWeaponNum();        // Do nothing we have no unit selected.        if ( null == ce() ) {            return;        }        // If the weapon does not have modes, just exit.        Mounted m = ce().getEquipment(wn);        if ( m == null || !m.getType().hasModes() ) {            return;        }                //disables mode button for AC's if maxtech_rapid_ac is not turned on        if (  m.getType()instanceof WeaponType               && (((WeaponType)m.getType()).getAmmoType() == AmmoType.T_AC || ((WeaponType)m.getType()).getAmmoType() == AmmoType.T_LAC )                && !clientgui.getClient().game.getOptions().booleanOption("maxtech_rapid_ac") ) {            return;        }                // send change to the server        int nMode = m.switchMode();        client.sendModeChange(cen, wn, nMode);                // notify the player        if (m.getType().hasInstantModeSwitch()) {            clientgui.systemMessage(Messages.getString("FiringDisplay.switched", new Object[]{m.getName(), m.curMode().getDisplayableName()})); //$NON-NLS-1$        }        else {            clientgui.systemMessage(Messages.getString("FiringDisplay.willSwitch", new Object[]{m.getName(), m.pendingMode().getDisplayableName()})); //$NON-NLS-1$        }        this.updateTarget();        clientgui.mechD.wPan.displayMech(ce());        clientgui.mechD.wPan.selectWeapon(wn);    }   /**     * Cache the list of visible targets. This is used for the 'next target' button.     *     * We'll sort it by range to us.     */      private void cacheVisibleTargets() {        clearVisibleTargets();                Vector vec = client.game.getValidTargets( ce() );        Comparator sortComp = new Comparator() {          public int compare(java.lang.Object x, java.lang.Object y) {            Entity entX = (Entity)x;            Entity entY = (Entity)y;                    int rangeToX = ce().getPosition().distance(entX.getPosition());            int rangeToY = ce().getPosition().distance(entY.getPosition());                    if ( rangeToX == rangeToY ) return ((entX.getId() < entY.getId()) ? -1 : 1);                      return ((rangeToX < rangeToY) ? -1 : 1);          }        };                  TreeSet tree = new TreeSet(sortComp);        visibleTargets = new Entity[vec.size()];                      for ( int i = 0; i < vec.size(); i++ ) {          tree.add(vec.elementAt(i));          }                Iterator it = tree.iterator();        int count = 0;        while ( it.hasNext() ) {          visibleTargets[count++] = (Entity)it.next();        }        setNextTargetEnabled(visibleTargets.length > 0);      }      private void clearVisibleTargets() {        visibleTargets = null;        lastTargetID = -1;        setNextTargetEnabled(false);      }          /**     * Get the next target. Return null if we don't have any targets.     */      private Entity getNextTarget() {        if ( null == visibleTargets )          return null;                lastTargetID++;        if ( lastTargetID >= visibleTargets.length )          lastTargetID = 0;                return visibleTargets[lastTargetID];      }        /**     * Jump to our next target. If there isn't one, well, don't do anything.     */      private void jumpToNextTarget() {        Entity targ = getNextTarget();                if ( null == targ )          return;        // HACK : don't show the choice dialog.        this.showTargetChoice = false;        clientgui.bv.centerOnHex(targ.getPosition());        clientgui.getBoardView().select(targ.getPosition());        // HACK : show the choice dialog again.        this.showTargetChoice = true;        target(targ);    }        /**     * Called when the current entity is done firing.  Send out our attack     * queue to the server.     */    private void ready() {        if (attacks.isEmpty() && GUIPreferences.getInstance().getNagForNoAction()) {            // comfirm this action            String title = Messages.getString("FiringDisplay.DontFireDialog.title"); //$NON-NLS-1$            String body = Messages.getString("FiringDisplay.DontFireDialog.message"); //$NON-NLS-1$            ConfirmDialog response = clientgui.doYesNoBotherDialog(title, body);            if ( !response.getShowAgain() ) {                GUIPreferences.getInstance().setNagForNoAction(false);            }            if ( !response.getAnswer() ) {                return;            }        }        // auto spot if we can and the option is set        if (attacks.isEmpty() &&             client.game.getOptions().booleanOption("auto_spot") && //$NON-NLS-1$                client.game.getPhase() == IGame.PHASE_FIRING) {            if (!ce().isINarcedWith( INarcPod.HAYWIRE)) {                // if we might do physicals, ask for confirmation                if (ce().isEligibleForPhysical()) {                    doSpot();                // else, spot without asking                } else {                    attacks.addElement(new SpotAction(cen));                }            }        }        // stop further input (hopefully)        disableButtons();        // remove temporary attacks from game & board        removeTempAttacks();                // For bug 1002223        // Re-compute the to-hit numbers by adding in correct order.        Vector newAttacks = new Vector();        for (Enumeration e=attacks.elements(); e.hasMoreElements();) {            Object o = e.nextElement();            if (o instanceof WeaponAttackAction) {                WeaponAttackAction waa = (WeaponAttackAction)o;                Entity attacker = waa.getEntity(client.game);                Targetable target = waa.getTarget(client.game);                boolean curInFrontArc = Compute.isInArc(attacker.getPosition(), attacker.getSecondaryFacing(), target.getPosition(), Compute.ARC_FORWARD);                if (curInFrontArc) {                    WeaponAttackAction waa2 = new WeaponAttackAction(waa.getEntityId(), waa.getTargetType(), waa.getTargetId(), waa.getWeaponId());                    waa2.setAimedLocation(waa.getAimedLocation());                    waa2.setAimingMode(waa.getAimingMode());                    waa2.setOtherAttackInfo(waa.getOtherAttackInfo());                    newAttacks.addElement(waa2);                }            } else {                newAttacks.addElement(o);            }        }        for (Enumeration e=attacks.elements(); e.hasMoreElements();) {            Object o = e.nextElement();            if (o instanceof WeaponAttackAction) {                WeaponAttackAction waa = (WeaponAttackAction) o;                Entity attacker = waa.getEntity(client.game);                Targetable target = waa.getTarget(client.game);                boolean curInFrontArc = Compute.isInArc(attacker.getPosition(), attacker.getSecondaryFacing(), target.getPosition(), Compute.ARC_FORWARD);                if (!curInFrontArc) {                    WeaponAttackAction waa2 = new WeaponAttackAction(waa.getEntityId(), waa.getTargetType(), waa.getTargetId(), waa.getWeaponId() );                    waa2.setAimedLocation(waa.getAimedLocation());                    waa2.setAimingMode(waa.getAimingMode());                    waa2.setOtherAttackInfo(waa.getOtherAttackInfo());                    newAttacks.addElement(waa2);                }            }        }                // send out attacks        client.sendAttackData(cen, newAttacks);                // clear queue        attacks.removeAllElements();        // Clear the menu bar.        clientgui.getMenuBar().setEntity( null );        // close aimed shot display, if any        ash.closeDialog();        ash.lockLocation(false);    }        private void doSearchlight() {        // validate        if (ce() == null || target == null) {            throw new IllegalArgumentException("current searchlight parameters are invalid"); //$NON-NLS-1$        }        if(!SearchlightAttackAction.isPossible(client.game,cen,target,null))            return;        //create and queue a searchlight action        SearchlightAttackAction saa = new SearchlightAttackAction(cen, target.getTargetType(), target.getTargetId());        attacks.addElement(saa);        // and add it into the game, temporarily        client.game.addAction(saa);        clientgui.bv.addAttack(saa);        clientgui.bv.repaint(100);        clientgui.minimap.drawMap();        //refresh weapon panel, as bth will have changed        updateTarget();    }    /**     * Adds a weapon attack with the currently selected weapon to the attack     * queue.     */    private void fire() {        // get the selected weaponnum        int weaponNum = clientgui.mechD.wPan.getSelectedWeaponNum();        Mounted mounted = ce().getEquipment(weaponNum);                // validate        if (ce() == null || target == null || mounted == null         || !(mounted.getType() instanceof WeaponType)) {            throw new IllegalArgumentException("current fire parameters are invalid"); //$NON-NLS-1$        }                // declare searchlight, if possible        if(GUIPreferences.getInstance().getAutoDeclareSearchlight()) {            doSearchlight();        }        WeaponAttackAction waa = new WeaponAttackAction(cen, target.getTargetType(),                 target.getTargetId(), weaponNum);        if ( null != mounted.getLinked() &&              ((WeaponType)mounted.getType()).getAmmoType() != AmmoType.T_NA ) {            Mounted ammoMount = mounted.getLinked();            AmmoType ammoType = (AmmoType)ammoMount.getType();            waa.setAmmoId(ce().getEquipmentNum(ammoMount));            if ( ((ammoType.getMunitionType() == AmmoType.M_THUNDER_VIBRABOMB)                && (ammoType.getAmmoType() == AmmoType.T_LRM))                 || ammoType.getMunitionType() == AmmoType.M_VIBRABOMB_IV)                             {                VibrabombSettingDialog vsd  =                    new VibrabombSettingDialog( clientgui.frame );                vsd.setVisible(true);                waa.setOtherAttackInfo(vsd.getSetting());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -