Package megamek.common

Examples of megamek.common.Coords


                entitySpriteIds);

        if (sprite != null) {
            newSprites.remove(sprite);
        }
        Coords position = entity.getPosition();
        if (position != null) {
            sprite = new EntitySprite(entity);
            newSprites.add(sprite);
            newSpriteIds.put(entityId, sprite);
        }
View Full Code Here


     *            the x coordinate.
     * @param y
     *            the y coordinate.
     */
    public void select(int x, int y) {
        select(new Coords(x, y));
    }
View Full Code Here

     *            the x coordinate.
     * @param y
     *            the y coordinate.
     */
    public void highlight(int x, int y) {
        highlight(new Coords(x, y));
    }
View Full Code Here

     *            the x coordinate.
     * @param y
     *            the y coordinate.
     */
    public void cursor(int x, int y) {
        cursor(new Coords(x, y));
    }
View Full Code Here

     * Determines if this Board contains the (x, y) Coords, and if so, notifies listeners about the
     * specified mouse action.
     */
    public void mouseAction(int x, int y, int mtype, int modifiers) {
        if (game.getBoard().contains(x, y)) {
            Coords c = new Coords(x, y);
            switch (mtype) {
            case BOARD_HEX_CLICK:
                if ((modifiers & java.awt.event.InputEvent.CTRL_MASK) != 0) {
                    checkLOS(c);
                } else {
View Full Code Here

    // This is expensive, so precalculate when entity changes
    public void updateEcmList() {
        ArrayList<EcmBubble> list = new ArrayList<EcmBubble>();
        for (Enumeration<Entity> e = game.getEntities(); e.hasMoreElements();) {
            Entity ent = e.nextElement();
            Coords entPos = ent.getPosition();
            int range = ent.getECMRange();
            boolean deployed = ent.isDeployed();
            boolean offboard = ent.isOffBoard();
            if((entPos == null) && (ent.getTransportId() != Entity.NONE)) {
                Entity carrier = game.getEntity(ent.getTransportId());
                if((null != carrier) && carrier.loadedUnitsHaveActiveECM()) {
                    entPos = carrier.getPosition();
                    deployed = carrier.isDeployed();
                    offboard = carrier.isOffBoard();
                }
            }
            if ((entPos == null) || !deployed || offboard) {
                continue;
            }
            if (range != Entity.NONE) {
                int tint = PlayerColors.getColorRGB(ent.getOwner().getColorIndex());
                list.add(new EcmBubble(entPos, range, tint));
            }
            if(game.getBoard().inSpace()) {
                //then BAP is also ECCM so it needs a bubble
                range = ent.getBAPRange();
                int direction = -1;
                if (range != Entity.NONE) {
                    if(range > 6) {
                        direction = ent.getFacing();
                    }
                    int tint = PlayerColors.getColorRGB(ent.getOwner()
                            .getColorIndex());
                    list.add(new EcmBubble(entPos, range, tint, direction));
                }
            }
        }
        HashMap<Coords, Integer> table = new HashMap<Coords, Integer>();
        for (EcmBubble b : list) {
            Integer col = new Integer(b.tint);
            for (int x = -b.range; x <= b.range; x++) {
                for (int y = -b.range; y <= b.range; y++) {
                    Coords c = new Coords(x + b.x, y + b.y);
                    // clip rectangle to hexagon
                    if ((b.distance(c) <= b.range) && ((b.direction == -1) || Compute.isInArc(b, b.direction, c, Compute.ARC_NOSE))) {
                        Integer tint = table.get(c);
                        if (tint == null) {
                            table.put(c, col);
View Full Code Here

        IHex mhex = null;
        Point point = e.getPoint();

        // first, we have to determine how much text we are going to have
        // are we on a hex?
        final Coords mcoords = getCoordsAt(point);
        if (GUIPreferences.getInstance().getShowMapHexPopup() && game.getBoard().contains(mcoords)) {
            mhex = game.getBoard().getHex(mcoords);
            stringsSize += 1;
        }

        // check if it's on any entities
        for (EntitySprite eSprite : entitySprites) {
            if (eSprite.isInside(point)) {
                stringsSize += 3;
            }
        }

        // check if it's on any attacks
        for (AttackSprite aSprite : attackSprites) {
            if (aSprite.isInside(point)) {
                stringsSize += 1 + aSprite.weaponDescs.size();
            }
        }

        // If the hex contains a building, make more space.
        // Also if it contains other displayable terrain.
        if (mhex != null) {
            stringsSize += mhex.displayableTerrainsPresent();
            if (mhex.containsTerrain(Terrains.BUILDING)) {
                stringsSize++;
            }
            if (mhex.containsTerrain(Terrains.FUEL_TANK)) {
                stringsSize++;
            }
            if (mhex.containsTerrain(Terrains.BRIDGE)) {
                stringsSize++;
            }
        }

        stringsSize += game.getNbrMinefields(mcoords);

        // Artillery
        final ArrayList<ArtilleryAttackAction> artilleryAttacks = getArtilleryAttacksAtLocation(mcoords);
        stringsSize += artilleryAttacks.size();

        // Artillery fire adjustment
        final Mounted curWeapon = getSelectedArtilleryWeapon();
        if (curWeapon != null) {
            stringsSize++;
        }

        // if the size is zip, you must a'quit
        if (stringsSize == 0) {
            return null;
        }

        // now we can allocate an array of strings
        String[] strings = new String[stringsSize];
        int stringsIndex = 0;

        // are we on a hex?
        if (mhex != null) {
            strings[stringsIndex] = Messages.getString("BoardView1.Hex") + mcoords.getBoardNum() //$NON-NLS-1$
                    + Messages.getString("BoardView1.level") + mhex.getElevation(); //$NON-NLS-1$
            stringsIndex += 1;

            //cycle through the terrains and report types found
            //this will skip buildings and other constructed units
View Full Code Here

                            - 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));

            generateMountain(result, mountainWidth, peak, mountainHeight,
                    mapSettings.getMountainStyle());
View Full Code Here

        int height = building.getHeight();
        ITerrainFactory tf = Terrains.getTerrainFactory();
        ArrayList<IHex> hexes = new ArrayList<IHex>();
        int level = 0;
        for (Iterator<Coords> i = building.getCoords(); i.hasNext();) {
            Coords c = i.next();
            IHex hex = board.getHex(c);
            // work out exits...
            int exits = 0;
            for (int dir = 0; dir < 6; dir++) {
                if (building.containsCoords(c.translated(dir))) {
                    exits |= (1 << dir);
                }
            }

            // remove everything
View Full Code Here

        int elevation = board.getHex(c).getElevation();
        boolean higher = false;
        boolean lower = false;
        int count = 0;
        for (int dir = 0; dir < 6; dir++) {
            Coords t = c.translated(dir);
            if (board.contains(t)) {
                IHex hex = board.getHex(t);
                int el = hex.getElevation();
                if (el > elevation) {
                    lower = true;
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.