本文整理汇总了C#中IGameObject.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# IGameObject.GetLength方法的具体用法?C# IGameObject.GetLength怎么用?C# IGameObject.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGameObject
的用法示例。
在下文中一共展示了IGameObject.GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBoard
/// <summary>
/// Draws the game board on the console.
/// </summary>
/// <param name="board">The game board to be drawn.</param>
public void DrawBoard(IGameObject[,] board)
{
this.SetConsole();
int cols = board.GetLength(1);
// print first row
this.PrintIndentationOnTheLeft();
this.PrintFieldsNumberOfColumns(cols);
// print second row
this.PrintIndentationOnTheLeft();
this.PrintFieldTopAndBottomBorder(cols);
this.PrintGameField(board);
// print last row
this.PrintIndentationOnTheLeft();
this.PrintFieldTopAndBottomBorder(cols);
}
示例2: PrintGameField
private void PrintGameField(IGameObject[,] board)
{
int rows = board.GetLength(0);
int cols = board.GetLength(1);
for (int row = 0; row < rows; row++)
{
Console.Write(row + " | ");
for (int col = 0; col < cols; col++)
{
var currentCell = board[row, col];
var symbolToPrint = this.GetCellSymbol(currentCell);
if (this.skin.ColorScheme.ContainsKey(symbolToPrint) &&
currentCell.IsCellRevealed)
{
Console.ForegroundColor = this.skin.ColorScheme[symbolToPrint];
}
Console.Write(symbolToPrint + " ");
Console.ResetColor();
}
Console.WriteLine("|");
}
}