本文整理汇总了C#中BlockType.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# BlockType.GetLength方法的具体用法?C# BlockType.GetLength怎么用?C# BlockType.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockType
的用法示例。
在下文中一共展示了BlockType.GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getSuccesors
/// <summary>
/// returns a list of blocks that are accesable from the current block
/// </summary>
/// <param name="currentNode"> current position </param>
/// <param name="Grid"> The grid information </param>
/// <returns></returns>
///
List<Node> getSuccesors(Node currentNode, BlockType[,] Grid, successorCheck isSuccessor)
{
List<Node> successors = new List<Node>();
int GridHeight = Grid.GetLength(0); //get the dimensions of the grid
int GridWidth = Grid.GetLength(1);
//for every possible add the possible successors to the list
for (int i = 0; i < Enum.GetNames(typeof(Action)).Length; i++)
{
Node successor = new Node(currentNode);
successor.pos = currentNode.pos;
switch ((Action)i)
{
case Action.Left:
{
successor.pos.column--;
if (successor.pos.column >= 0 && isSuccessor(successor, Grid)) //if the block is not out of bounds and satisfies the conditions of isSuccessor, add it
successors.Add(successor);
break;
}
case Action.Right:
{
successor.pos.column++;
if (successor.pos.column < GridWidth && isSuccessor(successor, Grid))
successors.Add(successor);
break;
}
case Action.Up:
{
successor.pos.row--;
if (successor.pos.row >= 0 && isSuccessor(successor, Grid))
successors.Add(successor);
break;
}
case Action.Down:
{
successor.pos.row++;
if (successor.pos.row < GridHeight && isSuccessor(successor, Grid))
successors.Add(successor);
break;
}
}
}
return successors;
}