本文整理汇总了Java中net.sf.freecol.common.model.Tile.isExplored方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.isExplored方法的具体用法?Java Tile.isExplored怎么用?Java Tile.isExplored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.model.Tile
的用法示例。
在下文中一共展示了Tile.isExplored方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateGotoPath
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void updateGotoPath(Tile tile) {
final Unit unit = getActiveUnit();
if (tile == null || unit == null) {
canvas.stopGoto();
return;
}
if (!canvas.isGotoStarted()) return;
// Do nothing if the tile has not changed.
PathNode oldPath = canvas.getGotoPath();
Tile lastTile = (oldPath == null) ? null
: oldPath.getLastNode().getTile();
if (lastTile == tile) return;
// Do not show a path if it will be invalid, avoiding calling
// the expensive path finder if possible.
PathNode newPath = (unit.getTile() == tile
|| !tile.isExplored()
|| !unit.getSimpleMoveType(tile).isLegal()) ? null
: unit.findPath(tile);
canvas.setGotoPath(newPath);
}
示例2: addTile
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Adds a tile entry to this popup.
*
* @param tile The tile that will be represented on the popup.
*/
private void addTile(final Tile tile) {
JMenuItem menuItem = new JMenuItem(Messages.message(tile.getLabel()));
if (tile.isExplored()) {
menuItem.addActionListener((ActionEvent ae) -> {
gui.showTilePanel(tile);
});
}
add(menuItem);
/**
* Don't set hasAnItem to true, we want the tile panel to open
* automatically whenever there is no other item on the list.
*/
// hasAnItem = true;
}
示例3: createTileImageWithBeachBorderAndItems
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Create a {@code BufferedImage} and draw a {@code Tile} on it.
* Draws the terrain and improvements.
*
* @param tile The Tile to draw.
* @return The image.
*/
BufferedImage createTileImageWithBeachBorderAndItems(Tile tile) {
if (!tile.isExplored())
return lib.getTerrainImage(null, tile.getX(), tile.getY());
final TileType tileType = tile.getType();
Dimension terrainTileSize = lib.tileSize;
BufferedImage overlayImage = lib.getOverlayImage(tile);
final int compoundHeight = (overlayImage != null)
? overlayImage.getHeight()
: tileType.isForested()
? lib.tileForestSize.height
: terrainTileSize.height;
BufferedImage image = new BufferedImage(
terrainTileSize.width, compoundHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.translate(0, compoundHeight - terrainTileSize.height);
displayTileWithBeachAndBorder(g, tile);
displayTileItems(g, tile, null, overlayImage);
g.dispose();
return image;
}
示例4: showTilePopup
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Shows a tile popup.
*
* @param tile The Tile where the popup occurred.
* @param x The x-coordinate on the screen where the popup needs to be
* placed.
* @param y The y-coordinate on the screen where the popup needs to be
* placed.
* @see TilePopup
*/
public void showTilePopup(Tile tile, int x, int y) {
if (tile == null)
return;
TilePopup tp = new TilePopup(freeColClient, this, tile);
if (tp.hasItem()) {
tp.show(this, x, y);
tp.repaint();
} else if (tile.isExplored()) {
showTilePanel(tile);
}
}
示例5: displayTile
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Displays the given {@code Tile}.
*
* @param g The Graphics2D on which to draw the {@code Tile}.
* @param tile The {@code Tile} to draw.
* @param overlayImage The BufferedImage for the tile overlay.
*/
private void displayTile(Graphics2D g, Tile tile, BufferedImage overlayImage) {
displayTileWithBeachAndBorder(g, tile);
if (tile.isExplored()) {
RescaleOp rop = hasFogOfWar(tile)
? new RescaleOp(new float[] { 0.8f, 0.8f, 0.8f, 1f },
new float[] { 0, 0, 0, 0 },
null)
: null;
displayTileItems(g, tile, rop, overlayImage);
displaySettlementWithChipsOrPopulationNumber(g, tile, false, rop);
displayOptionalTileText(g, tile);
}
}
示例6: displayUnknownTileBorder
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
void displayUnknownTileBorder(Graphics2D g, Tile tile) {
if (tile.isExplored()) {
for (Direction direction : Direction.values()) {
Tile borderingTile = tile.getNeighbourOrNull(direction);
if (borderingTile != null && !borderingTile.isExplored()) {
g.drawImage(lib.getBorderImage(
null, direction, tile.getX(), tile.getY()),
0, 0, null);
}
}
}
}
示例7: mouseMoved
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Invoked when the mouse has been moved.
*
* @param e The MouseEvent that holds all the information.
*/
@Override
public void mouseMoved(MouseEvent e) {
performAutoScrollIfActive(e, true);
if (canvas.isGotoStarted()) {
if (canvas.getActiveUnit() == null) {
canvas.stopGoto();
}
Tile tile = canvas.convertToMapTile(e.getX(), e.getY());
if (tile != null) {
if (lastTile != tile) {
Unit active = canvas.getActiveUnit();
lastTile = tile;
PathNode dragPath = null;
// Only call the expensive path finder if there
// are no obvious showstoppers.
if (active != null && active.getTile() != tile
&& tile.isExplored()
&& active.getSimpleMoveType(tile).isLegal()) {
dragPath = active.findPath(tile);
}
canvas.setGotoPath(dragPath);
}
}
}
}
示例8: displayTileWithBeachAndBorder
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Displays the given Tile onto the given Graphics2D object at the
* location specified by the coordinates. Only base terrain will be drawn.
*
* @param g The Graphics2D object on which to draw the Tile.
* @param tile The Tile to draw.
*/
void displayTileWithBeachAndBorder(Graphics2D g, Tile tile) {
if (tile != null) {
TileType tileType = tile.getType();
int x = tile.getX();
int y = tile.getY();
// ATTENTION: we assume that all base tiles have the same size
g.drawImage(lib.getTerrainImage(tileType, x, y),
0, 0, null);
if (tile.isExplored()) {
if (!tile.isLand() && tile.getStyle() > 0) {
int edgeStyle = tile.getStyle() >> 4;
if (edgeStyle > 0) {
g.drawImage(lib.getBeachEdgeImage(edgeStyle, x, y),
0, 0, null);
}
int cornerStyle = tile.getStyle() & 15;
if (cornerStyle > 0) {
g.drawImage(lib.getBeachCornerImage(cornerStyle, x, y),
0, 0, null);
}
}
List<SortableImage> imageBorders = new ArrayList<>(8);
SortableImage si;
for (Direction direction : Direction.values()) {
Tile borderingTile = tile.getNeighbourOrNull(direction);
if (borderingTile != null && borderingTile.isExplored()) {
TileType borderingTileType = borderingTile.getType();
if (borderingTileType != tileType) {
if (!tile.isLand() && borderingTile.isLand()) {
// If there is a Coast image (eg. beach) defined, use it, otherwise skip
// Draw the grass from the neighboring tile, spilling over on the side of this tile
si = new SortableImage(
lib.getBorderImage(borderingTileType, direction, x, y),
borderingTileType.getIndex());
imageBorders.add(si);
TileImprovement river = borderingTile.getRiver();
if (river != null) {
int magnitude = river.getRiverConnection(
direction.getReverseDirection());
if (magnitude > 0) {
si = new SortableImage(
lib.getRiverMouthImage(direction,
magnitude, x, y),
-1);
imageBorders.add(si);
}
}
} else if (!tile.isLand() || borderingTile.isLand()) {
if (borderingTileType.getIndex() < tileType.getIndex() &&
!lib.getTerrainImage(tileType, 0, 0).equals(lib.getTerrainImage(borderingTileType, 0, 0))) {
// Draw land terrain with bordering land type, or ocean/high seas limit,
// if the tiles do not share same graphics (ocean & great river)
si = new SortableImage(
lib.getBorderImage(borderingTileType, direction, x, y),
borderingTileType.getIndex());
imageBorders.add(si);
}
}
}
}
}
for (SortableImage sorted : sort(imageBorders)) {
g.drawImage(sorted.image, 0, 0, null);
}
}
}
}
示例9: 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;
}
示例10: showTilePanel
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Display the tile panel for a given tile.
*
* @param tile The {@code Tile} to display.
*/
public void showTilePanel(Tile tile) {
if (tile == null || !tile.isExplored()) return;
showSubPanel(new TilePanel(freeColClient, tile), false);
}