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


Java Tile.hasRiver方法代码示例

本文整理汇总了Java中net.sf.freecol.common.model.Tile.hasRiver方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.hasRiver方法的具体用法?Java Tile.hasRiver怎么用?Java Tile.hasRiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.freecol.common.model.Tile的用法示例。


在下文中一共展示了Tile.hasRiver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
@Override
public void transform(Tile tile) {
    TileImprovementType riverType =
        tile.getSpecification().getTileImprovementType("model.improvement.river");

    if (riverType.isTileTypeAllowed(tile.getType())) {
        if (!tile.hasRiver()) {
            StringBuilder sb = new StringBuilder(64);
            for (Direction direction : Direction.longSides) {
                Tile t = tile.getNeighbourOrNull(direction);
                TileImprovement otherRiver = (t == null) ? null
                    : t.getRiver();
                if (t == null || (t.isLand() && otherRiver == null)) {
                    sb.append('0');
                } else {
                    sb.append(magnitude);
                }
            }
            tile.addRiver(magnitude, sb.toString());
        } else {
            tile.removeRiver();
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:25,代码来源:MapEditorTransformPanel.java

示例2: perhapsAddBonus

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Adds a terrain bonus with a probability determined by the
 * {@code MapGeneratorOptions}.
 *
 * @param t The {@code Tile} to add bonuses to.
 * @param generateBonus Generate the bonus or not.
 */
private void perhapsAddBonus(Tile t, boolean generateBonus) {
    final Game game = t.getGame();
    final OptionGroup mapOptions = game.getMapGeneratorOptions();
    final Specification spec = game.getSpecification();
    TileImprovementType fishBonusLandType
        = spec.getTileImprovementType("model.improvement.fishBonusLand");
    TileImprovementType fishBonusRiverType
        = spec.getTileImprovementType("model.improvement.fishBonusRiver");
    final int bonusNumber
        = mapOptions.getRange(MapGeneratorOptions.BONUS_NUMBER);
    if (t.isLand()) {
        if (generateBonus
            && randomInt(logger, "Land Resource", random, 100) < bonusNumber) {
            // Create random Bonus Resource
            t.addResource(createResource(t));
        }
    } else {
        int adjacentLand = 0;
        boolean adjacentRiver = false;
        for (Direction direction : Direction.values()) {
            Tile otherTile = t.getNeighbourOrNull(direction);
            if (otherTile != null && otherTile.isLand()) {
                adjacentLand++;
                if (otherTile.hasRiver()) {
                    adjacentRiver = true;
                }
            }
        }

        // In Col1, ocean tiles with less than 3 land neighbours
        // produce 2 fish, all others produce 4 fish
        if (adjacentLand > 2) {
            t.add(new TileImprovement(game, t, fishBonusLandType, null));
        }

        // In Col1, the ocean tile in front of a river mouth would
        // get an additional +1 bonus
        // FIXME: This probably has some false positives, means
        // river tiles that are NOT a river mouth next to this tile!
        if (!t.hasRiver() && adjacentRiver) {
            t.add(new TileImprovement(game, t, fishBonusRiverType, null));
        }

        if (t.getType().isHighSeasConnected()) {
            if (generateBonus && adjacentLand > 1
                && randomInt(logger, "Sea resource", random,
                             10 - adjacentLand) == 0) {
                t.addResource(createResource(t));
            }
        } else {
            if (randomInt(logger, "Water resource", random, 100) < bonusNumber) {
                // Create random Bonus Resource
                t.addResource(createResource(t));
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:65,代码来源:TerrainGenerator.java


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