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

📄 physicaldisplay.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        if ((b.getModifiers() & InputEvent.CTRL_MASK) != 0) {            return;        }        if (client.isMyTurn()                && (b.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {            if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) {                if (!b.getCoords().equals(clientgui.getBoardView().getLastCursor())) {                    clientgui.getBoardView().cursor(b.getCoords());                }            } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) {                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) {            final Targetable targ = this.chooseTarget(b.getCoords());            if (targ != null) {                target(targ);            } else {                target(null);            }        }    }    /**     * 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) {        // Assume that we have *no* choice.        Targetable choice = null;        // Get the available choices.        Enumeration choices = client.game.getEntities(pos);        // 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));        }        // Is the attacker targeting its own hex?        if (ce().getPosition().equals(pos)) {            // Add any iNarc pods attached to the entity.            Enumeration pods = ce().getINarcPodsAttached();            while (pods.hasMoreElements()) {                choice = (Targetable) pods.nextElement();                targets.addElement(choice);            }        }        // 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("PhysicalDisplay.ChooseTargetDialog.title"), //$NON-NLS-1$                            Messages.getString("PhysicalDisplay.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 )    //    // GameListener    //    public void gameTurnChange(GameTurnChangeEvent e) {        // Are we ignoring events?        if (this.isIgnoringEvents()) {            return;        }        if (client.game.getPhase() == IGame.PHASE_PHYSICAL) {            endMyTurn();            if (client.isMyTurn()) {                beginMyTurn();                setStatusBarText(Messages.getString("PhysicalDisplay.its_your_turn")); //$NON-NLS-1$            } else {                setStatusBarText(Messages.getString("PhysicalDisplay.its_others_turn", new Object[]{e.getPlayer().getName()})); //$NON-NLS-1$            }        } else {            System.err.println("PhysicalDisplay: got turnchange event when it's not the physical attacks phase"); //$NON-NLS-1$        }    }    public void gamePhaseChange(GamePhaseChangeEvent e) {        // Are we ignoring events?        if (this.isIgnoringEvents()) {            return;        }        if (client.isMyTurn() && client.game.getPhase() != IGame.PHASE_PHYSICAL) {            endMyTurn();        }        // if we're ending the firing phase, unregister stuff.        if (client.game.getPhase() == IGame.PHASE_PHYSICAL) {            setStatusBarText(Messages.getString("PhysicalDisplay.waitingForPhysicalAttackPhase")); //$NON-NLS-1$        }    }    //    // ActionListener    //    public void actionPerformed(ActionEvent ev) {        // Are we ignoring events?        if (this.isIgnoringEvents()) {            return;        }        if (statusBarActionPerformed(ev, client))            return;        if (!client.isMyTurn()) {            // odd...            return;        }        if (ev.getSource() == butDone) {            ready();        } else if (ev.getActionCommand().equals(PHYSICAL_PUNCH)) {            punch();        } else if (ev.getActionCommand().equals(PHYSICAL_KICK)) {            kick();        } else if (ev.getActionCommand().equals(PHYSICAL_PUSH)) {            push();        } else if (ev.getActionCommand().equals(PHYSICAL_TRIP)) {            trip();        } else if (ev.getActionCommand().equals(PHYSICAL_GRAPPLE)) {            doGrapple();        } else if (ev.getActionCommand().equals(PHYSICAL_JUMPJET)) {            jumpjetatt();        } else if (ev.getActionCommand().equals(PHYSICAL_CLUB)) {            club();        } else if (ev.getActionCommand().equals(PHYSICAL_BRUSH_OFF)) {            brush();        } else if (ev.getActionCommand().equals(PHYSICAL_THRASH)) {            thrash();        } else if (ev.getActionCommand().equals(PHYSICAL_DODGE)) {            dodge();        } else if (ev.getActionCommand().equals(PHYSICAL_PROTO)) {            proto();        } else if (ev.getActionCommand().equals(PHYSICAL_EXPLOSIVES)) {            explosives();        } else if (ev.getActionCommand().equals(PHYSICAL_NEXT)) {            selectEntity(client.getNextEntityNum(cen));        } else if (ev.getActionCommand().equals(PHYSICAL_SEARCHLIGHT)) {            doSearchlight();        } else if (ev.getSource() == butMore) {            buttonLayout++;            if (buttonLayout >= NUM_BUTTON_LAYOUTS)                buttonLayout = 0;            setupButtonPanel();        }    }    //    // KeyListener    //    public void keyPressed(KeyEvent ev) {        // Are we ignoring events?        if (this.isIgnoringEvents()) {            return;        }        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE) {            clearattacks();        } else if (ev.getKeyCode() == KeyEvent.VK_ENTER && ev.isControlDown()) {            if (client.isMyTurn()) {                //            }        }    }    public void keyReleased(KeyEvent ev) {    }    public void keyTyped(KeyEvent ev) {    }    //    // BoardViewListener    //    public void finishedMovingUnits(BoardViewEvent b) {    }    public void unitSelected(BoardViewEvent b) {        // Are we ignoring events?        if (this.isIgnoringEvents()) {            return;        }        Entity e = client.game.getEntity(b.getEntityId());        if (client.isMyTurn()) {            if (client.game.getTurn().isValidEntity(e, client.game)) {                selectEntity(e.getId());            }        } else {            clientgui.setDisplayVisible(true);            clientgui.mechD.displayEntity(e);            if (e.isDeployed()) {                clientgui.bv.centerOnHex(e.getPosition());            }        }    }    public void setThrashEnabled(boolean enabled) {        butThrash.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalThrashEnabled(enabled);    }    public void setPunchEnabled(boolean enabled) {        butPunch.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalPunchEnabled(enabled);    }    public void setKickEnabled(boolean enabled) {        butKick.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalKickEnabled(enabled);    }    public void setPushEnabled(boolean enabled) {        butPush.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalPushEnabled(enabled);    }    public void setTripEnabled(boolean enabled) {        butTrip.setEnabled(enabled);    }    public void setGrappleEnabled(boolean enabled) {        butGrapple.setEnabled(enabled);    }    public void setJumpJetEnabled(boolean enabled) {        butJumpJet.setEnabled(enabled);    }    public void setClubEnabled(boolean enabled) {        butClub.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalClubEnabled(enabled);    }    public void setBrushOffEnabled(boolean enabled) {        butBrush.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalBrushOffEnabled(enabled);    }    public void setDodgeEnabled(boolean enabled) {        butDodge.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalDodgeEnabled(enabled);    }    public void setProtoEnabled(boolean enabled) {        butProto.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalProtoEnabled(enabled);    }    public void setExplosivesEnabled(boolean enabled) {        butExplosives.setEnabled(enabled);        //clientgui.getMenuBar().setExplosivesEnabled(enabled);    }    public void setNextEnabled(boolean enabled) {        butNext.setEnabled(enabled);        clientgui.getMenuBar().setPhysicalNextEnabled(enabled);    }    private void setSearchlightEnabled(boolean enabled) {        butSearchlight.setEnabled(enabled);        clientgui.getMenuBar().setFireSearchlightEnabled(enabled);    }    /**     * 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 distracted <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);    }    /**     * Stop just ignoring events and actually stop listening to them.     */    public void removeAllListeners() {        client.game.removeGameListener(this);        clientgui.getBoardView().removeBoardViewListener(this);    }    /**     * Retrieve the "Done" button of this object.     *     * @return the <code>javax.swing.JButton</code> that activates this     *         object's "Done" action.     */    public JButton getDoneButton() {        return butDone;    }}

⌨️ 快捷键说明

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