本文整理汇总了C#中GridNode.GetConnection方法的典型用法代码示例。如果您正苦于以下问题:C# GridNode.GetConnection方法的具体用法?C# GridNode.GetConnection怎么用?C# GridNode.GetConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridNode
的用法示例。
在下文中一共展示了GridNode.GetConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckConnection
/** Returns if \a node is connected to it's neighbour in the specified direction.
* This will also return true if #neighbours = NumNeighbours.Four, the direction is diagonal and one can move through one of the adjacent nodes
* to the targeted node.
*/
public bool CheckConnection(GridNode node, int dir)
{
if (neighbours == NumNeighbours.Eight) {
return node.GetConnection (dir);
} else {
int dir1 = (dir-4-1) & 0x3;
int dir2 = (dir-4+1) & 0x3;
if (!node.GetConnection (dir1) || !node.GetConnection (dir2)) {
return false;
} else {
GridNode n1 = nodes[node.GetIndex ()+neighbourOffsets[dir1]] as GridNode;
GridNode n2 = nodes[node.GetIndex ()+neighbourOffsets[dir2]] as GridNode;
if (!n1.walkable || !n2.walkable) {
return false;
}
if (!n2.GetConnection (dir1) || !n1.GetConnection (dir2)) {
return false;
}
}
return true;
}
}