本文整理汇总了C#中Tile.IsOccupied方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.IsOccupied方法的具体用法?C# Tile.IsOccupied怎么用?C# Tile.IsOccupied使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.IsOccupied方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateDistanceAndUpdatePath
public static void CalculateDistanceAndUpdatePath(Tile currentTile, Tile neighbor,
Dictionary<Tile, int> tileToDistance, Dictionary<Tile, Tile> tileToOptimalPrevious,
bool moveThroughOccupied)
{
if (neighbor == null || (neighbor.IsOccupied() && !moveThroughOccupied)) {
return;
}
int totalDistance = tileToDistance[currentTile] + 1;
if (!tileToDistance.ContainsKey(neighbor)) {
tileToDistance.Add(neighbor, totalDistance);
tileToOptimalPrevious[neighbor] = currentTile;
} else if (totalDistance < tileToDistance[neighbor]) {
tileToDistance[neighbor] = totalDistance;
tileToOptimalPrevious[neighbor] = currentTile;
}
}
示例2: IsTraversable
public static bool IsTraversable(Tile tile, bool moveThroughOccupiedTiles)
{
return (tile != null && ( !tile.IsOccupied() || moveThroughOccupiedTiles));
}
示例3: TileIsFree
protected bool TileIsFree(Tile tile, int radius)
{
// make sure that given tile, and all tiles around in given radius are not occupied
// if there is not tile, tile is not free
if (tile == null) { return false; }
// if tile is occupied, tile is not free
if (tile.IsOccupied()) { return false; }
// if any tile inside given radius is occupied, tile is not free
List<Tile> tiles = grid.GetNeighboursInsideRadius(tile.x, tile.y, radius);
foreach (Tile neighbour in tiles) {
if (neighbour.IsOccupied()) { return false; }
}
// there is a door adjacent to the tile in 4 directions, tile is not free
if (IsAdjacentToDoor(tile.x, tile.y)) { return false; }
// otherwise, tile is free
return true;
}