Package org.freerealm.map

Examples of org.freerealm.map.Coordinate


        while (workforceIterator.hasNext()) {
            Entry entry = (Entry) workforceIterator.next();
            WorkForce workForce = (WorkForce) entry.getValue();
            Resource workForceResource = workForce.getResource();
            if (resource.equals(workForceResource)) {
                Coordinate coordinate = (Coordinate) entry.getKey();
                Tile tile = getRealm().getTile(coordinate);
                int producedQuantity = tile.getProduction(resource) * workForce.getNumberOfWorkers();
                totalProduction = totalProduction + producedQuantity;
            }
        }
View Full Code Here


                newAbscissa = coordinate.getAbscissa() + (coordinate.getOrdinate() % 2);
                newOrdinate = coordinate.getOrdinate() + 1;
                break;
        }
        newAbscissa = (newAbscissa + realm.getMapWidth()) % realm.getMapWidth();
        Coordinate relativeCoordinate = new Coordinate(newAbscissa, newOrdinate);
        if (isValidCoordinate(realm, relativeCoordinate)) {
            return relativeCoordinate;
        } else {
            return null;
        }
View Full Code Here

    }

    public static Direction getDirection(Realm realm, Coordinate coordinate, Coordinate directionCoordinate) {
        for (int i = 0; i < RealmConstants.directions.length; i++) {
            Direction direction = RealmConstants.directions[i];
            Coordinate tryCoordinate = Utility.getRelativeCoordinate(realm, coordinate, direction);
            if (directionCoordinate.equals(tryCoordinate)) {
                return direction;
            }
        }
        return null;
View Full Code Here

        return getCircleCoordinates(coordinate1, realm, 1).contains(coordinate2);
    }

    public static Vector<Coordinate> getCircleCoordinates(Coordinate coordinate, Realm realm, int distance) {
        Vector<Coordinate> coordinates = new Vector<Coordinate>();
        Coordinate relativeCoordinate = new Coordinate(coordinate.getAbscissa(), coordinate.getOrdinate() - 2 * distance);
        coordinates.add(relativeCoordinate);
        for (int i = 0; i < distance * 2; i++) {
            relativeCoordinate = relativeCoordinate.getRelativeCoordinate(RealmConstants.SOUTHEAST);
            relativeCoordinate.setAbscissa((relativeCoordinate.getAbscissa() + realm.getMapWidth()) % realm.getMapWidth());
            if (isValidCoordinate(realm, relativeCoordinate)) {
                coordinates.add(relativeCoordinate);
            }
        }
        for (int i = 0; i < distance * 2; i++) {
            relativeCoordinate = relativeCoordinate.getRelativeCoordinate(RealmConstants.SOUTHWEST);
            relativeCoordinate.setAbscissa((relativeCoordinate.getAbscissa() + realm.getMapWidth()) % realm.getMapWidth());
            if (isValidCoordinate(realm, relativeCoordinate)) {
                coordinates.add(relativeCoordinate);
            }
        }
        for (int i = 0; i < distance * 2; i++) {
            relativeCoordinate = relativeCoordinate.getRelativeCoordinate(RealmConstants.NORTHWEST);
            relativeCoordinate.setAbscissa((relativeCoordinate.getAbscissa() + realm.getMapWidth()) % realm.getMapWidth());
            if (isValidCoordinate(realm, relativeCoordinate)) {
                coordinates.add(relativeCoordinate);
            }
        }
        for (int i = 0; i < distance * 2 - 1; i++) {
            relativeCoordinate = relativeCoordinate.getRelativeCoordinate(RealmConstants.NORTHEAST);
            relativeCoordinate.setAbscissa((relativeCoordinate.getAbscissa() + realm.getMapWidth()) % realm.getMapWidth());
            if (isValidCoordinate(realm, relativeCoordinate)) {
                coordinates.add(relativeCoordinate);
            }
        }
        return coordinates;
View Full Code Here

    }

    public void addExploredCoordinates(Vector<Coordinate> coordinates) {
        Iterator<Coordinate> iterator = coordinates.iterator();
        while (iterator.hasNext()) {
            Coordinate coordinate = iterator.next();
            addExploredCoordinate(coordinate);
        }
    }
View Full Code Here

    }

    private Coordinate normalizeCoordinate(Coordinate coordinate) {
        if (isValidCoordinate(coordinate)) {
            int abscissa = (coordinate.getAbscissa() + getMapWidth()) % getMapWidth();
            return new Coordinate(abscissa, coordinate.getOrdinate());
        } else {
            return null;
        }
    }
View Full Code Here

    }

    public Vector<Coordinate> normalizeCoordinates(Vector<Coordinate> coordinates) {
        Vector<Coordinate> normalizedCoordinates = new Vector<Coordinate>();
        for (Coordinate coordinate : coordinates) {
            Coordinate normalizedCoordinate = normalizeCoordinate(coordinate);
            if (normalizedCoordinate != null) {
                normalizedCoordinates.add(normalizedCoordinate);
            }
        }
        return normalizedCoordinates;
View Full Code Here

TOP

Related Classes of org.freerealm.map.Coordinate

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.