Package megamek.common

Examples of megamek.common.Board


                File fBoard = new File(boardDir, sBoardFile);
                if (!fBoard.exists()) {
                    throw new Exception("Scenario requires nonexistant board: "
                            + sBoard);
                }
                ba[n] = new Board();
                ba[n].load(sBoardFile);
                if (cf > 0) {
                    ba[n].setBridgeCF(cf);
                }
                BoardUtilities.flip(ba[n], isRotated, isRotated);
View Full Code Here


                    roadsAutoExit = false;
                }
            }
        }

        IBoard result = new Board();
        result.setRoadsAutoExit(roadsAutoExit);
        // Initialize all hexes - buildings, exits, etc
        result.newData(resultWidth, resultHeight, resultData);

        //assuming that the map setting and board types match
        result.setType(medium);
       
        return result;
    }
View Full Code Here

                            .getTheme());
                }
            }
        }

        IBoard result = new Board(mapSettings.getBoardWidth(), mapSettings
                .getBoardHeight(), nb);
       
        if(mapSettings.getMedium() == MapSettings.MEDIUM_SPACE) {
            result.setType(Board.T_SPACE);
            return result;
        }
       
        /* initalize reverseHex */
        HashMap<IHex, Point> reverseHex = new HashMap<IHex, Point>(2
                * mapSettings.getBoardWidth() * mapSettings.getBoardHeight());
        for (int y = 0; y < mapSettings.getBoardHeight(); y++) {
            for (int x = 0; x < mapSettings.getBoardWidth(); x++) {
                reverseHex.put(result.getHex(x, y), new Point(x, y));
            }
        }

        int peaks = mapSettings.getMountainPeaks();
        while (peaks > 0) {
            peaks--;
            int mountainHeight = mapSettings.getMountainHeightMin()
                    + Compute.randomInt(1 + mapSettings.getMountainHeightMax()
                            - mapSettings.getMountainHeightMin());
            int mountainWidth = mapSettings.getMountainWidthMin()
                    + Compute.randomInt(1 + mapSettings.getMountainWidthMax()
                            - mapSettings.getMountainWidthMin());
            int mapWidth = result.getWidth();
            int mapHeight = result.getHeight();

            // put the peak somewhere in the middle of the map...
            Coords peak = new Coords(mapWidth / 4
                    + Compute.randomInt((mapWidth + 1) / 2), mapHeight / 4
                    + Compute.randomInt((mapHeight + 1) / 2));
View Full Code Here

    public void applyBoardSettings() {
        mapSettings.replaceBoardWithRandom(MapSettings.BOARD_RANDOM);
        mapSettings.replaceBoardWithRandom(MapSettings.BOARD_SURPRISE);
        IBoard[] sheetBoards = new IBoard[mapSettings.getMapWidth() * mapSettings.getMapHeight()];
        for (int i = 0; i < mapSettings.getMapWidth() * mapSettings.getMapHeight(); i++) {
            sheetBoards[i] = new Board();
            String name = mapSettings.getBoardsSelectedVector().get(i);
            boolean isRotated = false;
            if (name.startsWith(Board.BOARD_REQUEST_ROTATION)) {
                // only rotate boards with an even width
                if (mapSettings.getBoardWidth() % 2 == 0) {
View Full Code Here

    }

    public void previewBoard() {
        String boardName = (String) lisBoardsAvailable.getSelectedValue();
        if (lisBoardsAvailable.getSelectedIndex() > 2) {
            IBoard board = new Board(Integer.parseInt(texBoardWidth.getText()),
                    Integer.parseInt(texBoardHeight.getText()));
            board.load(boardName + ".board");
            if (chkRotateBoard.isSelected()) {
                BoardUtilities.flip(board, true, true);
            }
            MapPreview mapPreview = null;
            try {
View Full Code Here

    }

    public void previewBoard() {
        String boardName = lisBoardsAvailable.getSelectedItem();
        if (lisBoardsAvailable.getSelectedIndex() > 2) {
            IBoard board = new Board(new Integer(texBoardWidth.getText()),
                    new Integer(texBoardHeight.getText()));
            board.load(boardName + ".board");
            if (chkRotateBoard.getState()) {
                BoardUtilities.flip(board, true, true);
            }
            MapPreview mapPreview = null;
            try {
View Full Code Here

            // conn = new XmlConnection( this, new Socket(host, port), 1 );
            System.out.println("Connected to peer.");
            conn.addConnectionListener(connectionListener);

            board = new Board();
            panConnect.setEnabled(false);
            panXmit.setEnabled(true);
        } catch (Throwable err) {
            err.printStackTrace();
        }
View Full Code Here

            conn = ConnectionFactory.getInstance().createServerConnection(s, 0);
            // conn = new XmlConnection(this, s, 0);
            conn.addConnectionListener(connectionListener);

            board = new Board();
            panConnect.setEnabled(false);
            panXmit.setEnabled(true);

        } catch (Throwable err) {
            err.printStackTrace();
View Full Code Here

                case Packet.COMMAND_SENDING_BOARD:
                    System.out.print("COMMAND_SENDING_BOARD");
                    /*
                     * * Save the board here.
                     */
                    Board recvBoard = (Board) packet.getObject(0);
                    try {
                        recvBoard.save(new FileOutputStream("xmit.board"));
                    } catch (IOException ioErr) {
                        ioErr.printStackTrace();
                    }
                    break;
                case Packet.COMMAND_SENDING_ENTITIES:
View Full Code Here

public class TestOffBoardEntity {

    public static void main(String[] args) {
        // Give the game a blank map.
        Game game = new Game();
        game.board = new Board(16, 17);

        // Now create an entity in the game.
        Entity entity = new BipedMech();
        entity.setGame(game);
View Full Code Here

TOP

Related Classes of megamek.common.Board

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.