Examples of IBoard


Examples of megamek.common.IBoard

        if (game.getOptions().booleanOption("tacops_start_fire") && (game.getPlanetaryConditions().getAtmosphere() >= PlanetaryConditions.ATMO_TRACE)) {
            int rear = (ae.getFacing() + 3) % 6;
            Coords src = ae.getPosition();
            Coords rearCoords = src.translated(rear);
            IBoard board = game.getBoard();
            IHex currentHex = board.getHex(src);

            if (!board.contains(rearCoords)) {
                rearCoords = src;
            } else if (board.getHex(rearCoords).getElevation() > currentHex.getElevation() + 4) {
                rearCoords = src;
            } else if ((board.getBuildingAt(rearCoords) != null) && (board.getHex(rearCoords).terrainLevel(Terrains.BLDG_ELEV) + board.getHex(rearCoords).getElevation() > currentHex.getElevation() + 4)) {
                rearCoords = src;
            }

            server.createSmoke(rearCoords,2,2);
        }
View Full Code Here

Examples of megamek.common.IBoard

        boolean roadsAutoExit = true;

        // Copy the data from the sub-boards.
        for (int i = 0; i < sheetHeight; i++) {
            for (int j = 0; j < sheetWidth; j++) {
                IBoard b = boards[i * sheetWidth + j];
                if (b.getWidth() != width || b.getHeight() != height) {
                    throw new IllegalArgumentException(
                            "board is the wrong size, expected " + width + "x"
                                    + height + ", got " + b.getWidth() + "x"
                                    + b.getHeight());
                }
                copyBoardInto(resultData, resultWidth, j * width, i * height,
                        boards[i * sheetWidth + j]);
                // Copy in the other board's options.
                if (boards[i * sheetWidth + j].getRoadsAutoExit() == false) {
                    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

Examples of megamek.common.IBoard

                            .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

Examples of megamek.common.IBoard

    /**
     * Load all the images we'll need for the game and place them in the tracker
     */
    public void loadNeededImages(IGame game) {
        loaded = false;
        IBoard board = game.getBoard();
        // pre-match all hexes with images, load hex images
        for (int y = 0; y < board.getHeight(); y++) {
            for (int x = 0; x < board.getWidth(); x++) {
                IHex hex = board.getHex(x, y);
                loadHexImage(hex);
            }
        }

        // load all mech images
View Full Code Here

Examples of megamek.common.IBoard

    }

    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

Examples of megamek.common.IBoard

    }

    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

Examples of megamek.common.IBoard

            }
        }
    }

    private void findGeysers() {
        IBoard b = server.getGame().getBoard();
        int height = b.getHeight();
        int width = b.getWidth();
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                if (b.getHex(x, y).containsTerrain(Terrains.GEYSER)) {
                    geysers.add(new GeyserInfo(new Coords(x, y)));
                }
            }
        }
    }
View Full Code Here

Examples of megamek.common.IBoard

     */
    public static void main(String[] args) {

        // The Game containing the Board.
        IGame game = new Game();
        IBoard board = game.getBoard();
        Coords coords = null;
        boolean success = true;

        // Try to conduct the test.
        try {
            // The serialized board *before* it is encoded.
            ByteArrayOutputStream before = new ByteArrayOutputStream();
            GZIPOutputStream bzos = new GZIPOutputStream(before);
            ObjectOutputStream boos = new ObjectOutputStream(bzos);

            // The serialized board *after* it is encoded
            ByteArrayOutputStream after = new ByteArrayOutputStream();
            GZIPOutputStream azos = new GZIPOutputStream(after);
            ObjectOutputStream aoos = new ObjectOutputStream(azos);

            // The character writer for encoding.
            CharArrayWriter to = new CharArrayWriter();

            // Load the test board.
            board.load(TestBoardEncoder.getTestInputStream());

            // Add some infernos and fires.
            ITerrainFactory f = Terrains.getTerrainFactory();
            coords = new Coords(5, 3);
            board.addInfernoTo(coords, InfernoTracker.STANDARD_ROUND, 1);
            board.getHex(coords).addTerrain(f.createTerrain(Terrains.FIRE, 1));
            coords = new Coords(8, 6);
            board.addInfernoTo(coords, InfernoTracker.STANDARD_ROUND, 1);
            board.getHex(coords).addTerrain(f.createTerrain(Terrains.FIRE, 2));
            coords = new Coords(4, 10);
            board.getHex(coords).addTerrain(f.createTerrain(Terrains.FIRE, 2));
            coords = new Coords(7, 13);
            board.addInfernoTo(coords, InfernoTracker.STANDARD_ROUND, 2);
            board.getHex(coords).addTerrain(f.createTerrain(Terrains.FIRE, 2));
            coords = new Coords(11, 14);
            board.getHex(coords).addTerrain(f.createTerrain(Terrains.FIRE, 2));

            // Save a copy of the board before XML encoding.
            boos.writeObject(board);
            boos.close();

View Full Code Here

Examples of megamek.common.IBoard

                add(ea);
            }
        }

        if (selectedWeapon != null && selectedEntity != null) {
            IBoard gboard = game.getBoard();
            Coords c = new Coords();
            for (c.y = 0; c.y < gboard.getHeight(); c.y++) {
                for (c.x = 0; c.x < gboard.getWidth(); c.x++) {
                    if (selectedEntity.getOwner().getArtyAutoHitHexes().contains(c)) {
                        addChild(new ArtilleryAttackModel(TilesetManager.ARTILLERY_AUTOHIT, c, game, tileManager));
                    } else if (selectedEntity.aTracker.getModifier(selectedWeapon, c) != 0) {
                        addChild(new ArtilleryAttackModel(TilesetManager.ARTILLERY_ADJUSTED, c, game, tileManager));
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.