Package org.freerealm.map

Examples of org.freerealm.map.Coordinate


        xml.append("</builtTileImprovementsCount>\n");

        xml.append("<exploredCoordinates>\n");
        Iterator<Coordinate> exploredCoordinatesIterator = player.getExploredCoordinates().iterator();
        while (exploredCoordinatesIterator.hasNext()) {
            Coordinate coordinate = exploredCoordinatesIterator.next();
            xml.append((new CoordinateXMLWrapper(coordinate)).toXML() + "\n");
        }
        xml.append("</exploredCoordinates>\n");

        xml.append("<missions>\n");
View Full Code Here


                } else if (subNode.getNodeName().equals("exploredCoordinates")) {
                    player.getExploredCoordinates().clear();
                    for (Node exploredCoordinateNode = subNode.getFirstChild(); exploredCoordinateNode != null; exploredCoordinateNode = exploredCoordinateNode.getNextSibling()) {
                        if (exploredCoordinateNode.getNodeType() == Node.ELEMENT_NODE) {
                            Coordinate exploredCoordinate = new Coordinate();
                            (new CoordinateXMLWrapper(exploredCoordinate)).initializeFromNode(realm, exploredCoordinateNode);
                            player.addExploredCoordinate(exploredCoordinate);
                        }
                    }
                } else if (subNode.getNodeName().equals("Properties")) {
View Full Code Here

                if ((i != 0 && i % (columnSegmentSize + 1) == 0) || (j != 0 && j % (rowSegmentSize + 1) == 0)) {
                    newTile = new Tile(generateTileType(realm, probabilityTotal));
                } else {
                    int targetX = i - i / columnSegmentSize;
                    int targetY = j - j / rowSegmentSize;
                    Coordinate coordinate = new Coordinate(targetX, targetY);
                    newTile = currentMap.getTile(coordinate);
                }
                mapItems[i][j] = newTile;
            }
        }
View Full Code Here

                if (subNode.getNodeName().equals("turnGiven")) {
                    String turnGivenString = subNode.getFirstChild().getNodeValue();
                    int turnGivenValue = Integer.parseInt(turnGivenString);
                    goToCoordinate.setTurnGiven(turnGivenValue);
                } else if (subNode.getNodeName().equals("Coordinate")) {
                    Coordinate coordinateValue = new Coordinate();
                    (new CoordinateXMLWrapper(coordinateValue)).initializeFromNode(realm, subNode);
                    goToCoordinate.setCoordinate(coordinateValue);
                }
            }
        }
View Full Code Here

                } else if (subNode.getNodeName().equals("type")) {
                    String unitTypeName = subNode.getFirstChild().getNodeValue();
                    UnitType unitType = realm.getUnitTypeManager().getUnitType(unitTypeName);
                    unit.setType(unitType);
                } else if (subNode.getNodeName().equals("Coordinate")) {
                    Coordinate coordinate = new Coordinate();
                    (new CoordinateXMLWrapper(coordinate)).initializeFromNode(realm, subNode);
                    unit.setCoordinate(coordinate);
                } else if (subNode.getNodeName().equals("ContainerManager")) {
                    unit.setContainerManager(new ContainerManagerXMLConverter(unit).initializeFromNode(realm, subNode));
                }
View Full Code Here

                    settlement.setPopulation(populationValue);
                } else if (subNode.getNodeName().equals("productionPoints")) {
                    int productionPointsValue = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    settlement.setProductionPoints(productionPointsValue);
                } else if (subNode.getNodeName().equals("Coordinate")) {
                    Coordinate coordinate = new Coordinate();
                    (new CoordinateXMLWrapper(coordinate)).initializeFromNode(realm, subNode);
                    settlement.setCoordinate(coordinate);
                } else if (subNode.getNodeName().equals("productionQueue")) {
                    for (Node queueItemNode = subNode.getFirstChild(); queueItemNode != null; queueItemNode = queueItemNode.getNextSibling()) {
                        if (queueItemNode.getNodeType() == Node.ELEMENT_NODE) {
View Full Code Here

                    workForce.setResource(resourceValue);
                } else if (subNode.getNodeName().equals("numberOfWorkers")) {
                    int numberOfWorkersValue = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    workForce.setNumberOfWorkers(numberOfWorkersValue);
                } else if (subNode.getNodeName().equals("Coordinate")) {
                    Coordinate coordinateValue = new Coordinate();
                    (new CoordinateXMLWrapper(coordinateValue)).initializeFromNode(realm, subNode);
                    workForce.setCoordinate(coordinateValue);
                }
            }
        }
View Full Code Here

            errorMessage = errorMessage + " Target coordinate :" + coordinate;
            return new CommandResult(CommandResult.RESULT_ERROR, errorMessage);
        }
        int i = 0;
        while ((unit.getMovementPoints() > 0) && (i < path.getLength())) {
            Coordinate pathCoordinate = path.getStep(i);
            Tile tile = realm.getTile(pathCoordinate);
            ICommand command = null;
            if (tile.getNumberOfUnits() > 0) {
                Unit tileUnit = tile.getUnits().get(tile.getUnits().firstKey());
                if (!unit.getPlayer().equals(tileUnit.getPlayer())) {
View Full Code Here

        if ((toTile.getSettlement() != null) && (!unit.getPlayer().equals((toTile.getSettlement().getPlayer())))) {
            return new CommandResult(CommandResult.RESULT_ERROR, "Tile contains a settlement that does not belong to player. Use InvadeCityCommand.");
        }

        Coordinate oldCoordinate = unit.getCoordinate();
        realm.getWorldMap().removeUnit(unit);
        unit.setCoordinate(coordinate);
        realm.getWorldMap().addUnit(unit);
        float movementCost = toTile.getMovementCost();
        float newMovementPoints = (unit.getMovementPoints() >= movementCost ? unit.getMovementPoints() - movementCost : 0);
View Full Code Here

            errorMessage = errorMessage + " Target coordinate :" + coordinate;
            return new CommandResult(CommandResult.RESULT_ERROR, errorMessage);
        }
        int i = 0;
        while ((unit.getMovementPoints() > 0) && (i < path.getLength())) {
            Coordinate pathCoordinate = path.getStep(i);
            MoveUnitCommand moveUnitCommand = new MoveUnitCommand(unit, pathCoordinate);
            CommandResult moveCommandResult = Executor.getInstance().execute(moveUnitCommand);
            if (moveCommandResult.getCode() == CommandResult.RESULT_ERROR) {
                return new CommandResult(CommandResult.RESULT_ERROR, "A move command returned an error. Error : " + moveCommandResult.getText());
            }
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.