Examples of IBoard


Examples of megamek.common.IBoard

        int drawX = view.x / (int) (HEX_WC * scale) - 1;
        int drawY = view.y / (int) (HEX_H * scale) - 1;

        int drawWidth = view.width / (int) (HEX_WC * scale) + 3;
        int drawHeight = view.height / (int) (HEX_H * scale) + 3;
        IBoard board = game.getBoard();
        // loop through the hexes
        for (int i = 0; i < drawHeight; i++) {
            for (int j = 0; j < drawWidth; j++) {
                Coords c = new Coords(j + drawX, i + drawY);
                Point p = getHexLocation(c);
                p.translate(-(view.x), -(view.y));
                if (board.isLegalDeployment(c, m_plDeployer)) {
                    backGraph.setColor(Color.yellow);
                    int[] xcoords = { p.x + (int) (21 * scale),
                            p.x + (int) (62 * scale), p.x + (int) (83 * scale),
                            p.x + (int) (83 * scale), p.x + (int) (62 * scale),
                            p.x + (int) (21 * scale), p.x, p.x };
View Full Code Here

Examples of megamek.common.IBoard

        int drawY = view.y / (int) (HEX_H * scale) - 1;

        int drawWidth = view.width / (int) (HEX_WC * scale) + 3;
        int drawHeight = view.height / (int) (HEX_H * scale) + 3;

        IBoard board = game.getBoard();
        // loop through the hexes
        for (int i = 0; i < drawHeight; i++) {
            for (int j = 0; j < drawWidth; j++) {
                Coords c = new Coords(j + drawX, i + drawY);
                Point p = getHexLocation(c);
                p.translate(-(view.x), -(view.y));

                if (!board.contains(c)) {
                    continue;
                }
                if (!game.containsMinefield(c)) {
                    continue;
                }
View Full Code Here

Examples of megamek.common.IBoard

     *
     * @param game the game to load for.
     */
    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

        }
    }

    private void resolveWeather() {
        ITerrainFactory tf = Terrains.getTerrainFactory();
        IBoard board = game.getBoard();
        int width = board.getWidth();
        int height = board.getHeight();
        PlanetaryConditions conditions = game.getPlanetaryConditions();
        boolean lightSnow = false;
        boolean deepSnow = false;
        boolean ice = false;
       
        if(!conditions.isTerrainAffected())
            return;
       
        debugTime("resolve weather 1", true);

        //first we need to increment the conditions
        if(conditions.getWeather() == PlanetaryConditions.WE_MOD_SNOW && game.getBoard().onGround()) {
            modSnowTurn = modSnowTurn + 1;
            if(modSnowTurn == 9) {
                lightSnow = true;
            }
            if(modSnowTurn == 19) {
                deepSnow = true;
                ice = true;
            }
        }
        if(conditions.getWeather() == PlanetaryConditions.WE_HEAVY_SNOW && game.getBoard().onGround()) { 
            heavySnowTurn = heavySnowTurn + 1;
            if(heavySnowTurn == 4) {
                lightSnow = true;
            }
            if(heavySnowTurn == 14) {
                deepSnow = true;
            }
            if(heavySnowTurn == 19) {
                ice = true;
            }
        }
        if(conditions.getWeather() == PlanetaryConditions.WE_SLEET && game.getBoard().onGround()) { 
            sleetTurn = sleetTurn + 1;
            if(sleetTurn == 14) {
                ice = true;
            }
        }
        if(conditions.getWeather() == PlanetaryConditions.WE_ICE_STORM && game.getBoard().onGround()) { 
            iceTurn = iceTurn + 1;
            if(iceTurn == 14) {
                ice = true;
            }
        }
       
        if(lightSnow) {
            Report r = new Report(5505, Report.PUBLIC);
            vPhaseReport.addElement(r);
        }
        if(deepSnow) {
            Report r = new Report(5510, Report.PUBLIC);
            vPhaseReport.addElement(r);
        }
        if(ice) {
            Report r = new Report(5515, Report.PUBLIC);
            vPhaseReport.addElement(r);
        }
           
        // Cycle through all hexes, checking for the appropriate weather changes
        for (int currentXCoord = 0; currentXCoord < width; currentXCoord++ ) {
            for (int currentYCoord = 0; currentYCoord < height; currentYCoord++) {
                Coords currentCoords = new Coords(currentXCoord, currentYCoord);
                IHex currentHex = board.getHex(currentXCoord, currentYCoord);

                //check for fires and potentially put them out
                if (currentHex.containsTerrain(Terrains.FIRE)) {
                    //only standard fires get put out
                    if(currentHex.terrainLevel(Terrains.FIRE) == 1) {
View Full Code Here

Examples of megamek.common.IBoard

    /**
     * Check or quicksand stuff
     */
    private void resolveQuicksand() {
        IBoard board = game.getBoard();
        int width = board.getWidth();
        int height = board.getHeight();
        // Cycle through all hexes, checking for screens
        debugTime("resolve quicksand 1", true);

        for (int currentXCoord = 0; currentXCoord < width; currentXCoord++ ) {

            for (int currentYCoord = 0; currentYCoord < height; currentYCoord++) {
                Coords currentCoords = new Coords(currentXCoord, currentYCoord);
                IHex currentHex = board.getHex(currentXCoord, currentYCoord);

                //check for quicksand that has been around at least one turn
                if(currentHex.terrainLevel(Terrains.SWAMP) == 3) {
                    //sink any units that occupy this hex
                    Enumeration<Entity> entities = game.getEntities(currentCoords);
View Full Code Here

Examples of megamek.common.IBoard

            server.sendChangedHex(c);
        }
    }

    private void findElevators() {
        IBoard b = server.getGame().getBoard();
        int height = b.getHeight();
        int width = b.getWidth();
        int exits = 0;
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                if (b.getHex(x, y).containsTerrain(Terrains.ELEVATOR)) {
                    exits = b.getHex(x, y).getTerrain(Terrains.ELEVATOR)
                            .getExits();
                    // add the elevator to each list it belongs in.
                    // exits are abused to hold which d6 roll(s) move this
                    // elevator
                    for (int z = 0; z < 6; z++) {
View Full Code Here

Examples of megamek.common.IBoard

    }

    public void update() {
        clear();
       
        final IBoard gboard = game.getBoard();
        if (gboard == null) return;

        for (Enumeration<?> i = game.getEntities(); i.hasMoreElements();) {
            update((Entity)i.nextElement(), null);
        }
View Full Code Here

Examples of megamek.common.IBoard

    private final BoardHexModel hexAt(int x, int y) {
        return ((BoardHexModel)getChild(y*w+x+KEEP));
    }
   
    void update(Player player) {
        IBoard gboard = game.getBoard();
        detach();

        if (gboard.getWidth() != w || gboard.getHeight() != h) {
            System.out.println("BoardModel: full rebuild");
            for (int i = this.numChildren()-1; i >= KEEP; i--) removeChild(i);

            w = gboard.getWidth();
            h = gboard.getHeight();

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    Coords c = new Coords(x, y);
                    BoardHexModel b = new BoardHexModel(game, c, gboard.getHex(c), tileManager, shared);
                    addChild(b);
                }
            }

            DirectionalLight pl = new DirectionalLight(
                true,
                new Color3f(0.5f, 0.45f, 0.4f),
                new Vector3f(-1, 1, -1)
            );
            pl.setInfluencingBounds(bounds);
            addChild(pl);
            pl = new DirectionalLight(
                true,
                new Color3f(0.5f, 0.45f, 0.4f),
                new Vector3f(-1, -0.5f, -2)
            );
            pl.setInfluencingBounds(bounds);
            addChild(pl);

            AmbientLight al = new AmbientLight(new Color3f(0.4f, 0.4f, 0.4f));
            al.setInfluencingBounds(bounds);
            addChild(al);
        } else {
            System.out.println("BoardModel: full update");
        }

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                hexAt(x, y).update(gboard.getHex(x, y), tileManager, player);
            }
        }
        if (!isDeploying) resetBoard();

        universe.addBranchGraph(this);
View Full Code Here

Examples of megamek.common.IBoard

            isDeploying = false;
            resetBoard();
            return;
        }
        isDeploying = true;
        IBoard gboard = game.getBoard();

        detach();
        Coords c = new Coords(0,0);
        for (c.y = 0; c.y < h; c.y++) {
            for (c.x = 0; c.x < w; c.x++) {
                if (!gboard.isLegalDeployment(c, deployer)) {
                    hexAt(c.x, c.y).darken();
                } else {
                    hexAt(c.x, c.y).setEffect(highlight);
                }
            }
View Full Code Here

Examples of megamek.common.IBoard

    public void set(MovePath md) {
        clear();
        if (md == null) return;
        cur = md;
        IBoard gboard = game.getBoard();
        int count = 0;
        for (Enumeration<?> i = md.getSteps(); i.hasMoreElements();) {
            MoveStep step = (MoveStep)i.nextElement();
            addChild(new MoveStepModel(step, count++, gboard.getHex(step.getPosition()), currentView));
        }
    }
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.