本文整理汇总了C#中IPlayer.MovePiece方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.MovePiece方法的具体用法?C# IPlayer.MovePiece怎么用?C# IPlayer.MovePiece使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlayer
的用法示例。
在下文中一共展示了IPlayer.MovePiece方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public static void ProcessRequest(HttpContextBase context, IPlayer player)
{
string boardCode = context.Request.Form["board"];//".......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... zzzzzzzz..";
string pieceCode = context.Request["piece"]; //"l";
IBoard board = Board.Parse(boardCode);
Piece piece = (Piece) Enum.Parse(typeof(Piece), new string(char.ToUpper(pieceCode[0]), 1));
TetrisMove move = player.MovePiece(board, piece);
context.Response.ContentType = "text/plain";
context.Response.Write(string.Format("position={0}°rees={1}", move.Position, move.Degrees));
}
示例2: Test
private static void Test(IPlayer player, int count)
{
Random random = new Random();
for (int game = 0; game < count; game++)
{
IBoard board = Board.Empty;
Piece pieceCode;
int[,] rotatedPieceData;
TetrisMove move;
do
{
int score;
board = board.Collapse(out score);
Console.WriteLine(board);
Console.WriteLine("---------- {0}", score);
int pieceIndex = random.Next(Pieces.Length);
pieceCode = Pieces[pieceIndex];
try
{
move = player.MovePiece(board, pieceCode);
CollectionAssert.Contains(Board.DegreesOptions, move.Degrees, "Degrees");
Assert.GreaterOrEqual(move.Position, 0, "Position");
int[,] pieceData = PieceData.All[pieceCode];
rotatedPieceData = Board.Rotate(pieceData, move.Degrees);
Assert.LessOrEqual(move.Position, 10 - rotatedPieceData.GetLength(1), "Position");
}
catch (Exception ex)
{
throw new AssertionException(ex.Message + " Piece is " + pieceCode + ".", ex);
}
} while (Board.TryUpdateBoard(rotatedPieceData, ref board, move.Position, char.ToLower(pieceCode.ToString()[0])));
}
}