本文整理汇总了Java中net.sf.freecol.common.model.Tile.getHighSeasCount方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.getHighSeasCount方法的具体用法?Java Tile.getHighSeasCount怎么用?Java Tile.getHighSeasCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.model.Tile
的用法示例。
在下文中一共展示了Tile.getHighSeasCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReduceHighSeasCountGoalDecider
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Get a goal decider to find tiles with a settlement with a lower
* high seas count than a unit currently has. Useful for tunnelling
* out of intermittantly blocked rivers.
*
* @param unit The {@code Unit} to get the goal decider for.
* @return A suitable {@code GoalDecider}.
*/
public static GoalDecider getReduceHighSeasCountGoalDecider(final Unit unit) {
return new GoalDecider() {
private PathNode goal = null;
private int score = unit.getTile().getHighSeasCount();
@Override
public PathNode getGoal() { return goal; }
@Override
public boolean hasSubGoals() { return true; }
@Override
public boolean check(Unit u, PathNode pathNode) {
Tile tile = pathNode.getTile();
if (tile.getHighSeasCount() < score) {
Settlement s = tile.getSettlement();
if (unit.getOwner().owns(s)) {
this.goal = pathNode;
this.score = tile.getHighSeasCount();
return true;
}
}
return false;
}
};
}
示例2: getCornerGoalDecider
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Get a goal decider to find tiles on river corners, preferring ones
* closest to the high seas. This is useful when a unit is stuck on
* a river. By moving to a corner (i.e. where another unit can get
* past it) the chance that the blockage clears is enhanced.
*
* @return A suitable goal decider.
*/
public static GoalDecider getCornerGoalDecider() {
return new GoalDecider() {
private PathNode goal = null;
private int score = Integer.MAX_VALUE;
@Override
public PathNode getGoal() { return goal; }
@Override
public boolean hasSubGoals() { return true; }
@Override
public boolean check(Unit u, PathNode pathNode) {
Tile tile = pathNode.getTile();
if (tile.getHighSeasCount() < score && tile.isRiverCorner()) {
score = tile.getHighSeasCount();
goal = pathNode;
return true;
}
return false;
}
};
}
示例3: displayOptionalTileText
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Displays the Tile text for a Tile.
* Shows tile names, coordinates and colony values.
*
* @param g The Graphics2D object on which the text gets drawn.
* @param tile The Tile to draw the text on.
*/
void displayOptionalTileText(Graphics2D g, Tile tile) {
String text = null;
int op = getClientOptions().getInteger(ClientOptions.DISPLAY_TILE_TEXT);
switch (op) {
case ClientOptions.DISPLAY_TILE_TEXT_NAMES:
text = Messages.getName(tile);
break;
case ClientOptions.DISPLAY_TILE_TEXT_OWNERS:
if (tile.getOwner() != null) {
text = Messages.message(tile.getOwner().getNationLabel());
}
break;
case ClientOptions.DISPLAY_TILE_TEXT_REGIONS:
if (tile.getRegion() != null) {
if (FreeColDebugger.isInDebugMode(FreeColDebugger.DebugMode.MENUS)
&& tile.getRegion().getName() == null) {
text = tile.getRegion().getSuffix();
} else {
text = Messages.message(tile.getRegion().getLabel());
}
}
break;
case ClientOptions.DISPLAY_TILE_TEXT_EMPTY:
break;
default:
logger.warning("displayTileText option " + op + " out of range");
break;
}
g.setColor(Color.BLACK);
g.setFont(FontLibrary.createFont(FontLibrary.FontType.NORMAL,
FontLibrary.FontSize.TINY, lib.getScaleFactor()));
if (text != null) {
int b = getBreakingPoint(text);
if (b == -1) {
g.drawString(text,
(tileWidth - g.getFontMetrics().stringWidth(text)) / 2,
(tileHeight - g.getFontMetrics().getAscent()) / 2);
} else {
g.drawString(text.substring(0, b),
(tileWidth - g.getFontMetrics().stringWidth(text.substring(0, b)))/2,
halfHeight - (g.getFontMetrics().getAscent()*2)/3);
g.drawString(text.substring(b+1),
(tileWidth - g.getFontMetrics().stringWidth(text.substring(b+1)))/2,
halfHeight + (g.getFontMetrics().getAscent()*2)/3);
}
}
if (FreeColDebugger.debugDisplayCoordinates()) {
String posString = tile.getX() + ", " + tile.getY();
if (tile.getHighSeasCount() >= 0) {
posString += "/" + Integer.toString(tile.getHighSeasCount());
}
g.drawString(posString,
(tileWidth - g.getFontMetrics().stringWidth(posString)) / 2,
(tileHeight - g.getFontMetrics().getAscent()) / 2);
}
String value = DebugUtils.getColonyValue(tile);
if (value != null) {
g.drawString(value,
(tileWidth - g.getFontMetrics().stringWidth(value)) / 2,
(tileHeight - g.getFontMetrics().getAscent()) / 2);
}
}