本文整理汇总了C#中IMap.TryGetAdjacentCell方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.TryGetAdjacentCell方法的具体用法?C# IMap.TryGetAdjacentCell怎么用?C# IMap.TryGetAdjacentCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMap
的用法示例。
在下文中一共展示了IMap.TryGetAdjacentCell方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCorridor
private void BuildCorridor(IMap map, MapCell currentCell)
{
MapCell nextCell;
var direction = Dir.Zero;
bool success;
do
{
_directionPicker.LastDirection = direction;
_directionPicker.ResetDirections();
var emptySide = currentCell.Sides
.Single(s => s.Value != Side.Wall)
.Key;
success = false;
do
{
direction = _directionPicker.NextDirectionExcept(emptySide);
success = map.TryGetAdjacentCell(currentCell, direction, out nextCell);
if (success)
{
map.CreateCorridorSide(currentCell, nextCell, direction, Side.Empty);
}
} while (_directionPicker.HasDirections && !success);
if (!success)
{
return;
}
} while (currentCell.IsDeadEnd);
}
示例2: TryPickRandomUnvisitedAdjacentCell
private bool TryPickRandomUnvisitedAdjacentCell(
IMap map, MapCell currentCell, out MapCell nextCell, out Dir direction)
{
var success = false;
do
{
direction = _directionPicker.NextDirection();
success = map.TryGetAdjacentCell(currentCell, direction, out nextCell)
&& !nextCell.IsVisited;
}
while (_directionPicker.HasDirections && !success);
return success;
}
示例3: HasAdjacentCorridor
private static bool HasAdjacentCorridor(
IMap map, MapCell currentCell, Dir dir)
{
MapCell adjacentCell;
return map.TryGetAdjacentCell(currentCell, dir, out adjacentCell)
&& adjacentCell.Sides[dir] != Side.Wall;
}