本文整理汇总了C#中GameBoard.IsInsideBoard方法的典型用法代码示例。如果您正苦于以下问题:C# GameBoard.IsInsideBoard方法的具体用法?C# GameBoard.IsInsideBoard怎么用?C# GameBoard.IsInsideBoard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameBoard
的用法示例。
在下文中一共展示了GameBoard.IsInsideBoard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractCommand
/// <summary>
/// Converts a string to a valid command in the context of a game board
/// </summary>
/// <param name="input">A string to parse the command from</param>
/// <param name="gameBoard">The context of validation</param>
/// <returns></returns>
public Command ExtractCommand(string input, GameBoard gameBoard)
{
Command command;
CommandType cmdType;
Position coordinates = new Position(0, 0);
string[] inputCommands = input.Split(' ');
cmdType = this.GetCommandType(inputCommands);
if (cmdType == CommandType.Flag || cmdType == CommandType.ValidMove)
{
try
{
coordinates = this.GetCoordinates(inputCommands, cmdType);
}
catch (Exception)
{
cmdType = CommandType.InvalidMove;
}
}
if (!gameBoard.IsInsideBoard(coordinates))
{
return new Command(CommandType.InvalidMove);
}
command = new Command(cmdType, coordinates);
return command;
}