本文整理汇总了Java中net.sf.freecol.common.model.Tile.isDirectlyHighSeasConnected方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.isDirectlyHighSeasConnected方法的具体用法?Java Tile.isDirectlyHighSeasConnected怎么用?Java Tile.isDirectlyHighSeasConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.model.Tile
的用法示例。
在下文中一共展示了Tile.isDirectlyHighSeasConnected方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTileFor
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
private Tile findTileFor(Map map, int row, int start, boolean startAtSea,
LogBuilder lb) {
Tile tile = null;
Tile seas = null;
int offset = (start == 0) ? 1 : -1;
for (int x = start; 0 <= x && x < map.getWidth(); x += offset) {
tile = map.getTile(x, row);
if (tile.isDirectlyHighSeasConnected()) {
seas = tile;
} else if (tile.isLand()) {
return (startAtSea) ? seas : tile;
}
}
lb.add("No land in row ", row, ".\n");
return null;
}
示例2: getHighSeasGoalDecider
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Gets a GoalDecider to find the closest high seas tile to a target.
* Used when arriving on the map from Europe.
*
* @return The high seas goal decider.
*/
public static GoalDecider getHighSeasGoalDecider() {
return new GoalDecider() {
private PathNode best = null;
@Override
public PathNode getGoal() { return best; }
@Override
public boolean hasSubGoals() { return false; }
@Override
public boolean check(Unit u, PathNode path) {
Tile tile = path.getTile();
if (tile != null
&& tile.isExploredBy(u.getOwner())
&& tile.isDirectlyHighSeasConnected()
&& (tile.getFirstUnit() == null
|| u.getOwner().owns(tile.getFirstUnit()))) {
if (best == null || path.getCost() < best.getCost()) {
best = path;
return true;
}
}
return false;
}
};
}
示例3: getSimpleHighSeasGoalDecider
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Build a simple goal decider to find the first high seas tile
* without using the unit parameter.
*
* @return A {@code GoalDecider} that finds the nearest high seas tile.
*/
public static GoalDecider getSimpleHighSeasGoalDecider() {
return new GoalDecider() {
private PathNode first = null;
@Override
public PathNode getGoal() { return first; }
@Override
public boolean hasSubGoals() { return false; }
@Override
public boolean check(Unit u, PathNode path) {
Tile tile = path.getTile();
if (tile != null
&& tile.isDirectlyHighSeasConnected()) {
first = path;
return true;
}
return false;
}
};
}
示例4: moveHighSeas
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Moves a unit onto the "high seas" in a specified direction following
* a move of MoveType.MOVE_HIGH_SEAS.
* This may result in a move to Europe, no move, or an ordinary move.
*
* @param unit The {@code Unit} to be moved.
* @param direction The direction in which to move.
* @return True if automatic movement of the unit can proceed.
*/
private boolean moveHighSeas(Unit unit, Direction direction) {
// Confirm moving to Europe if told to move to a null tile
// (FIXME: can this still happen?), or if crossing the boundary
// between coastal and high sea. Otherwise just move.
final Tile oldTile = unit.getTile();
final Tile newTile = oldTile.getNeighbourOrNull(direction);
if (newTile == null
|| (!oldTile.isDirectlyHighSeasConnected()
&& newTile.isDirectlyHighSeasConnected())) {
TradeRouteStop stop;
if (unit.getTradeRoute() != null
&& (stop = unit.getStop()) != null
&& TradeRoute.isStopValid(unit, stop)
&& stop.getLocation() instanceof Europe) {
return moveTowardEurope(unit, (Europe)stop.getLocation());
} else if (unit.getDestination() instanceof Europe) {
return moveTowardEurope(unit, (Europe)unit.getDestination());
} else if (getGUI().confirm(oldTile, StringTemplate
.template("highseas.text")
.addAmount("%number%", unit.getSailTurns()),
unit, "highseas.yes", "highseas.no")) {
return moveTowardEurope(unit, unit.getOwner().getEurope());
}
}
return moveTile(unit, direction);
}
示例5: getCost
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Determines the cost of a single move.
*
* @param unit The {@code Unit} making the move.
* @param oldLocation The {@code Location} we are moving from.
* @param newLocation The {@code Location} we are moving to.
* @param movesLeftBefore The moves left before making the move.
* @return The cost of moving the given unit from the
* {@code oldLocation} to the {@code newLocation}.
*/
@Override
public int getCost(final Unit unit, final Location oldLocation,
final Location newLocation, int movesLeftBefore) {
int cost = 0;
this.newTurns = 0;
Tile oldTile = oldLocation.getTile();
Tile newTile = newLocation.getTile();
if (oldLocation instanceof Europe) { // Coming from Europe
if (newLocation instanceof Europe
|| newTile == null
|| !newTile.isDirectlyHighSeasConnected()
|| !unit.getType().canMoveToHighSeas()) return ILLEGAL_MOVE;
newTurns = unit.getSailTurns();
movesLeft = unit.getInitialMovesLeft();
cost = newTurns * unit.getInitialMovesLeft();
} else if (oldTile == null) {
return ILLEGAL_MOVE;
} else if (newLocation instanceof Europe) { // Going to Europe
if (!unit.getType().canMoveToHighSeas()) return ILLEGAL_MOVE;
newTurns = unit.getSailTurns();
movesLeft = unit.getInitialMovesLeft();
cost = newTurns * unit.getInitialMovesLeft();
} else if (newTile == null || !newTile.isExplored()) {
return ILLEGAL_MOVE;
} else { // Moving between tiles
// Disallow illegal moves.
// Special moves and moving off a carrier consume a whole turn.
boolean consumeMove = false;
switch (unit.getSimpleMoveType(oldTile, newTile)) {
case MOVE_HIGH_SEAS:
break;
case ATTACK_UNIT:
// Ignore hostile units in the base case, treating attacks
// as moves.
case MOVE:
if (!unit.isOnCarrier()) break; // Fall through if disembarking.
case ATTACK_SETTLEMENT:
case EXPLORE_LOST_CITY_RUMOUR:
case EMBARK:
case ENTER_INDIAN_SETTLEMENT_WITH_FREE_COLONIST:
case ENTER_INDIAN_SETTLEMENT_WITH_SCOUT:
case ENTER_INDIAN_SETTLEMENT_WITH_MISSIONARY:
case ENTER_FOREIGN_COLONY_WITH_SCOUT:
case ENTER_SETTLEMENT_WITH_CARRIER_AND_GOODS:
consumeMove = true;
break;
default:
return ILLEGAL_MOVE;
}
cost = adjust(unit, oldTile, newTile, movesLeftBefore);
if (consumeMove) {
cost += this.movesLeft;
this.movesLeft = 0;
}
}
return cost;
}