本文整理汇总了C#中Cell.CellInDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.CellInDirection方法的具体用法?C# Cell.CellInDirection怎么用?C# Cell.CellInDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell.CellInDirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCellToRoom
/// <summary>
/// Adds the cell to given room.
/// </summary>
/// <returns>
/// Whether the cell was added
/// </returns>
/// <param name='newCell'>
/// Cell to add
/// </param>
/// <param name='inRoom'>
/// Room number to add to
/// </param>
bool AddCellToRoom( Cell newCell, int inRoom )
{
// Add walls between this and cells that have been set to other rooms
if ( newCell.room == 0 )
{
newCell.room = inRoom;
if ( newCell.x > 0 && newCell.CellInDirection( Direction.West ).room != 0 && newCell.CellInDirection( Direction.West ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
newCell.canGoWest = newCell.CellInDirection( Direction.West ).canGoEast = false;
if ( newCell.x < cellsPerSide - 1 && newCell.CellInDirection( Direction.East ).room != 0 && newCell.CellInDirection( Direction.East ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
newCell.canGoEast = newCell.CellInDirection( Direction.East ).canGoWest = false;
if ( newCell.y > 0 && newCell.CellInDirection( Direction.South ).room != 0 && newCell.CellInDirection( Direction.South ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
newCell.canGoSouth = newCell.CellInDirection( Direction.South ).canGoNorth = false;
if ( newCell.y < cellsPerSide - 1 && newCell.CellInDirection( Direction.North ).room != 0 && newCell.CellInDirection( Direction.North ).room != inRoom && SimpleRNG.GetUniform() < wallDensity )
newCell.canGoNorth = newCell.CellInDirection( Direction.North ).canGoSouth = false;
unassignedRooms.Remove( newCell );
return true;
}
return false;
}
示例2: OpenCellInDirection
/// <summary>
/// Opens the cell in direction.
/// </summary>
/// <param name='toOpen'>
/// To open.
/// </param>
/// <param name='inDir'>
/// In dir.
/// </param>
Cell OpenCellInDirection( Cell toOpen, Direction inDir )
{
Debug.Log( "Opening cell " + toOpen + " in direction " + inDir );
Cell nextCell = toOpen.CellInDirection( inDir );
if ( !toOpen.CanGoInDirection( inDir ) )
{
toOpen.SetOpenInDirection( inDir, true );
if ( nextCell.room == 0 )
Debug.LogWarning( "Wall made to uninitialised cell" );
nextCell.SetOpenInDirection( Cell.Reverse( inDir ), true );
// made connection to another room. Stop.
}
else
// add uninited cell towards startCell to current room
if ( nextCell.room != 0 )
{
Debug.LogWarning ( "No path to start, but can reach another room???" );
}
else
{
AddCellToRoom ( nextCell, toOpen.room );
}
return nextCell;
}