当前位置: 首页>>代码示例>>Java>>正文


Java Tile.getHighSeasCount方法代码示例

本文整理汇总了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;
        }
    };
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:33,代码来源:GoalDeciders.java

示例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;
        }
    };
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:30,代码来源:GoalDeciders.java

示例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);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:72,代码来源:TileViewer.java


注:本文中的net.sf.freecol.common.model.Tile.getHighSeasCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。