Package megamek.common

Examples of megamek.common.Coords


                    me.getModifiers()));
        }
    }

    public void mouseReleased(MouseEvent me) {
        Coords c = pickCoords(me);
        if (c == null) {
            return;
        }

        if (me.isPopupTrigger() && !me.isControlDown() && !dragged) {
View Full Code Here


                disp.isReleased();
                return;
            }
        }

        Coords c = pickCoords(me);
        if (c == null) {
            return;
        }

        if (me.isPopupTrigger() && !me.isControlDown()) {
            processBoardViewEvent(new BoardViewEvent(this, c, null, BoardViewEvent.BOARD_HEX_POPUP,
                    me.getModifiers()));
        } else if (me.getClickCount() == 1 && me.isControlDown()) {
            if (c.equals(hoverInfo.getLOS())) {
                firstLOSCursor.hide();
                hoverInfo.setLOS(null);
            } else {
                firstLOSCursor.move(c, game.getBoard().getHex(c));
                firstLOSCursor.setColor(LOS_COLOR);
View Full Code Here

        if (b != null) {
            b.addBoardListener(BoardView3D.this);
        }
        updateBoard();
        if (b != null) {
            centerOnHex(new Coords(0, 0));
        }
    }
View Full Code Here

    public void mouseDragged(MouseEvent me) {
        dragged = true;
    }

    public void mouseMoved(MouseEvent me) {
        Coords c = pickCoords(me);
        if ((c == null ? c != hoverInfo.coords : !c.equals(hoverInfo.coords))) {
            if (hoverInfo.getLOS() != null) {
                secondLOSCursor.move(c, game.getBoard().getHex(c));
                secondLOSCursor.setColor(LOS_COLOR);
            }
            hoverInfo.setPosition(c);
View Full Code Here

        Enumeration<Building> buildings = game.getBoard().getBuildings();
        while (buildings.hasMoreElements()) {
            Building bldg = buildings.nextElement();
            Enumeration<Coords> bldgCoords = bldg.getCoords();
            while (bldgCoords.hasMoreElements()) {
                Coords coords = bldgCoords.nextElement();
                if (bldg.isBurning(coords)) {
                    int cf = Math.max(bldg.getCurrentCF(coords) - 2, 0);
                    bldg.setCurrentCF(cf, coords);

                    // Does the building burn down?
                    if (cf == 0) {
                        r = new Report(5120, Report.PUBLIC);
                        r.add(bldg.getName());
                        vPhaseReport.addElement(r);
                    }

                    // If it doesn't collapse under its load, mark it for update.
                    else if (!server.checkForCollapse(bldg, positionMap, coords, false)) {
                        bldg.setPhaseCF(cf, coords);
                    }
                }

            }
         }

        debugTime("resolve fire 1", true);

        // Cycle through all hexes, checking for fire and the spread of fire
        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);

                if(currentHex.containsTerrain(Terrains.FIRE)) {
                    //If the woods has been cleared, or the building
                    // has collapsed put non-inferno fires out.
                    if ((currentHex.terrainLevel(Terrains.FIRE) == 1) && !currentHex.isIgnitable()) {
                        server.removeFire(currentCoords, "lack of fuel");
                        continue;
                    }

                    //only check spread for fires that didn't start this turn
                    if(currentHex.getFireTurn() > 0) {
                        //optional rule, woods burn down
                        if ((currentHex.containsTerrain(Terrains.WOODS) || currentHex
                                .containsTerrain(Terrains.JUNGLE))
                                && game.getOptions().booleanOption("woods_burn_down")) {
                            burnDownWoods(currentCoords);
                        }
                        //report and check for fire spread
                        r = new Report(5125, Report.PUBLIC);
                        if (currentHex.terrainLevel(Terrains.FIRE) == 2) {
                            r.messageId = 5130;
                        }
                        r.add(currentCoords.getBoardNum());
                        vPhaseReport.addElement(r);
                        spreadFire(currentXCoord, currentYCoord, windDirection, windStrength);
                    }
                }
            }
        }

        //Cycle through all hexes again, reporting new fires, spreading smoke, and incrementing the fire turn.
        //Can't do this in first loop because new fires may be spread
        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);

                if(currentHex.containsTerrain(Terrains.FIRE)) {
                    //was the fire started this turn?
                    if(currentHex.getFireTurn() == 0) {
                        //report fire started this round
                        r = new Report(5135, Report.PUBLIC);
                        r.add(currentCoords.getBoardNum());
                        vPhaseReport.addElement(r);

                        // If the hex contains a building, set it on fire.
                        Building bldg = game.getBoard().getBuildingAt(
                                currentCoords);
                        if (bldg != null) {
                            bldg.setBurning(true, currentCoords);
                        }
                    }

                    //check for any explosions
                    server.checkExplodeIndustrialZone(currentCoords, vPhaseReport);

                    //Add smoke (unless we are in a tornado)
                    boolean bInferno = currentHex.terrainLevel(Terrains.FIRE) == 2;
                    if (game.getPlanetaryConditions().getWindStrength() < PlanetaryConditions.WI_TORNADO_F13) {
                        ArrayList<Coords> smokeList = new ArrayList<Coords>();

                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, windDirection), Coords.yInDir(currentXCoord, currentYCoord, windDirection)));
                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection+1)%6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection+1)%6)));
                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection+5)%6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection+5)%6)));

                        server.addSmoke(smokeList, windDirection, bInferno);
                        board.initializeAround(currentXCoord, currentYCoord);
                    }
                    //increment the fire turn counter
View Full Code Here

    /**
     * Spreads the fire around the specified coordinates.
     */
    public void spreadFire(int x, int y, int windDir, int windStr) {
        Coords src = new Coords(x, y);
        Coords nextCoords = src.translated(windDir);

        //check for height differences between hexes
        //TODO: until further clarification only the heights matter (not the base elevation)
        //This means that a fire cannot spread from a level 6 building at base level 0 to
        //a level 1 building at base level 0, for example.

        int curHeight = game.getBoard().getHex(src).ceiling();

        TargetRoll directroll = new TargetRoll(9, "spread downwind");
        TargetRoll obliqueroll = new TargetRoll(11, "spread 60 degrees to downwind");

        if((windStr > PlanetaryConditions.WI_NONE) && (windStr < PlanetaryConditions.WI_STRONG_GALE)) {
            directroll.addModifier(-2, "light/moderate gale");
            obliqueroll.addModifier(-1, "light/moderate gale");
        }
        else if(windStr > PlanetaryConditions.WI_MOD_GALE) {
            directroll.addModifier(-3, "strong gale+");
            directroll.addModifier(-2, "strong gale+");
        }

        spreadFire(nextCoords, directroll, curHeight);

        // Spread to the next hex downwind on a 12 if the first hex wasn't
        // burning...
        // unless a higher hex intervenes
        IHex nextHex = game.getBoard().getHex(nextCoords);
        IHex jumpHex = game.getBoard().getHex(nextCoords.translated(windDir));
        if ((nextHex != null) && (jumpHex != null) && !(nextHex.containsTerrain(Terrains.FIRE))
                && ((curHeight >= nextHex.ceiling()) || (jumpHex.ceiling() >= nextHex.ceiling()))) {
            // we've already gone one step in the wind direction, now go another
            directroll.addModifier(3, "crossing non-burning hex");
            spreadFire(nextCoords.translated(windDir), directroll, curHeight);
        }

        // spread fire 60 degrees clockwise....
        spreadFire(src.translated((windDir + 1) % 6), obliqueroll, curHeight);

View Full Code Here

        for ( SmokeCloud cloud : server.getSmokeCloudList() ){
            smokeToAdd = new ArrayList<Coords>();
            for ( Coords currentCoords : cloud.getCoordsList() ){

                Coords smokeCoords = driftAddSmoke(currentCoords, windDir, windStr);
                //Smoke has Dissipated by moving into a hex with a greater then 4 elevation drop.
                if ( smokeCoords == null ){
                    Report r = new Report(5220, Report.PUBLIC);
                    r.add(currentCoords.getBoardNum());
                    vPhaseReport.addElement(r);
View Full Code Here

     * @param directionChanges How many times the smoke has tried to change directions to get around an obsticle.
     * @return
     */
    public Coords driftAddSmoke(Coords src, int windDir, int windStr, int directionChanges) {
        //Coords src = new Coords(x, y);
        Coords nextCoords = src.translated(windDir);
        IBoard board = game.getBoard();

        //if the wind conditions are calm, then don't drift it
        if(windStr == PlanetaryConditions.WI_NONE) {
            return src;
View Full Code Here

        debugTime("resolve screen 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 existence of screen
                if (currentHex.containsTerrain(Terrains.SCREEN)){

                    if(Compute.d6(2)>6) {
                        Report r = new Report(9075, Report.PUBLIC);
                        r.add(currentCoords.getBoardNum());
                        vPhaseReport.addElement(r);

                        currentHex.removeTerrain(Terrains.SCREEN);
                        server.sendChangedHex(currentCoords);
                    }
View Full Code Here

                && (target.getTargetType() == Targetable.TYPE_MINEFIELD_CLEAR)) {
            r = new Report(3255);
            r.indent(1);
            r.subject = subjectId;
            vPhaseReport.addElement(r);
            Coords coords = target.getPosition();

            Enumeration<Minefield> minefields = game.getMinefields(coords).elements();
            ArrayList<Minefield> mfRemoved = new ArrayList<Minefield>();
            while (minefields.hasMoreElements()) {
                Minefield mf = minefields.nextElement();
View Full Code Here

TOP

Related Classes of megamek.common.Coords

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.