Package megamek.common

Examples of megamek.common.Coords.distance()


                    continue;
                }

                int localdensity = mapSettings.getCityDensity();
                if (radius > 0) {
                    int distance = coord.distance(centre);
                    localdensity = (int) (mapSettings.getCityDensity() - (falloff
                            * distance * distance));
                }

                if (Compute.randomInt(100) > localdensity) {
View Full Code Here


        ITerrainFactory tf = Terrains.getTerrainFactory();

        for (int x = 0; x < mapW; x++) {
            for (int y = 0; y < mapH; y++) {
                Coords c = new Coords(x, y);
                int distance = c.distance(centre);
                int elev = (100 * height * (width - distance)) / width;
                elev = (elev / 100)
                        + (Compute.randomInt(100) < (elev % 100) ? 1 : 0);

                IHex hex = board.getHex(c);
View Full Code Here

                info = v.elementAt(i);
                tagger = game.getEntity(info.attackerId);
                if ((info.shots < info.priority) && !ae.isEnemyOf(tagger)) {
                    entityTarget = game.getEntity(info.targetId);
                    if ((entityTarget != null) && entityTarget.isOnSameSheet(tc)) {
                        if (tc.distance(entityTarget.getPosition()) < bestDistance) {
                            bestIndex = i;
                            bestDistance = tc.distance(entityTarget
                                    .getPosition());
                            if (!game.getOptions().booleanOption(
                                    "a4homing_target_area")) {
View Full Code Here

                if ((info.shots < info.priority) && !ae.isEnemyOf(tagger)) {
                    entityTarget = game.getEntity(info.targetId);
                    if ((entityTarget != null) && entityTarget.isOnSameSheet(tc)) {
                        if (tc.distance(entityTarget.getPosition()) < bestDistance) {
                            bestIndex = i;
                            bestDistance = tc.distance(entityTarget
                                    .getPosition());
                            if (!game.getOptions().booleanOption(
                                    "a4homing_target_area")) {
                                break; // first will do if mapsheets can't
                                // overlap
View Full Code Here

        valid_attackers = game.getEntities();
        while (valid_attackers.hasMoreElements()) {
            test_ent = valid_attackers.nextElement();
            if (test_ent.isDeployed()) {
                if (test_ent.isVisibleToEnemy()) {
                    if (cDeploy.distance(test_ent.getPosition()) <= (int) av_range) {
                        hex_count++;
                        x_ave += test_ent.getPosition().x;
                        y_ave += test_ent.getPosition().y;
                    }
                }
View Full Code Here

            server.sendServerChat(connId, "The ToHit from hex ("
                    + (start.x + 1) + ", " + (start.y + 1) + ") at elevation "
                    + elev1 + " to (" + (end.x + 1) + ", " + (end.y + 1)
                    + ") at elevation " + elev2 + " has a range of "
                    + start.distance(end) + " and a modifier of " + toHit1
                    + " and return fire has a modifier of " + toHit2 + ".");
        } catch (NumberFormatException nfe) {
        } catch (NullPointerException npe) {
        } catch (IndexOutOfBoundsException ioobe) {
        }
View Full Code Here

            toHit2 += thd.getDesc();

            return "The ToHit from hex (" + (start.x + 1) + ", "
                    + (start.y + 1) + ") at elevation " + elev1 + " to ("
                    + (end.x + 1) + ", " + (end.y + 1) + ") at elevation "
                    + elev2 + " has a range of " + start.distance(end)
                    + " and a modifier of " + toHit1
                    + " and return fire has a modifier of " + toHit2 + ".";
        } catch (NumberFormatException nfe) {
        } catch (NullPointerException npe) {
        } catch (IndexOutOfBoundsException ioobe) {
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.