本文整理汇总了C#中IMap.CreateCorridorSide方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.CreateCorridorSide方法的具体用法?C# IMap.CreateCorridorSide怎么用?C# IMap.CreateCorridorSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMap
的用法示例。
在下文中一共展示了IMap.CreateCorridorSide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: BuildCorridors
private void BuildCorridors(IMap map)
{
if (map.Any(c => c.IsVisited))
{
throw new InvalidOperationException(
"Map should not contain visited cells.");
}
MapCell nextCell;
var direction = Dir.Zero;
var currentCell = map.PickRandomCell();
map.Visit(currentCell);
bool success;
do
{
_directionPicker.LastDirection = direction;
_directionPicker.ResetDirections();
success = TryPickRandomUnvisitedAdjacentCell(
map, currentCell, out nextCell, out direction);
if (success)
{
map.CreateCorridorSide(currentCell, nextCell, direction, Side.Empty);
map.Visit(nextCell);
currentCell = nextCell;
nextCell = null;
}
else
{
currentCell = map.PickNextRandomVisitedCell(currentCell);
}
}
while (!map.AllVisited);
}