本文整理汇总了C#中Pawn.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.Offset方法的具体用法?C# Pawn.Offset怎么用?C# Pawn.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.Offset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PawnMovedButNotInBoard
public void PawnMovedButNotInBoard()
{
Board board = new Board(BoardCommon.GRID_12X8);
Pawn pawn = new Pawn("Add", board, new Point(board.Width / 2, board.Height / 2));
// Expect an ArgumentException because the pawn doesn't exist on the board yet
Assert.Throws<ArgumentException>(delegate () {
pawn.Offset(Point.One);
}, "Offset was called on a Pawn that was not added to a Board");
}
示例2: MoveIntoWall
public void MoveIntoWall()
{
Board board = new Board(BoardCommon.GRID_12X8);
Pawn pawn = new Pawn("Mover", board, Point.One, null, true, true);
board.AddPawn(pawn);
Point expectedPosition = new Point(2, 1);
bool moveRight = pawn.Offset(Point.Right);
Point position1 = pawn.Position;
bool moveUp = pawn.Offset(Point.Up);
Point position2 = pawn.Position;
Assert.IsTrue(moveRight, "Offset returned false when moving right");
Assert.AreEqual(expectedPosition, position1, "Pawn failed to move right to open tile");
Assert.IsFalse(moveUp, "Offset returned true when moving up into a wall");
Assert.AreEqual(expectedPosition, position2, "Pawn failed to stay on one goddamn place");
}
示例3: MoveSolidPawnIntoSolidPawn
public void MoveSolidPawnIntoSolidPawn()
{
Board board = new Board(BoardCommon.GRID_12X8);
Point pos1 = new Point(6, 4);
Point pos2 = new Point(8, 4);
Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true);
Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true);
board.AddPawn(pawn1);
board.AddPawn(pawn2);
Point expectedPosition = new Point(7, 4);
bool firstMove = pawn2.Offset(Point.Left);
Point firstPosition = pawn2.Position;
bool secondMove = pawn2.Offset(Point.Left);
Point secondPosition = pawn2.Position;
Assert.IsTrue(firstMove, "Pawn was not able to move left one tile");
Assert.IsFalse(secondMove, "Pawn somehow passed through another solid pawn");
Assert.AreEqual(expectedPosition, firstPosition, "Pawn could not move to free tile");
Assert.AreEqual(expectedPosition, secondPosition, "Pawn somehow passed through another solid pawn");
}
示例4: SolidPawnsMoveIntoSharedCell
public void SolidPawnsMoveIntoSharedCell()
{
Board board = new Board(BoardCommon.GRID_12X8);
Point pos1 = new Point(6, 4);
Point pos2 = new Point(8, 4);
Point pos3 = new Point(7, 4);
Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true);
Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true);
board.AddPawn(pawn1);
board.AddPawn(pawn2);
Assert.IsTrue(pawn1.Offset(Point.Right),"Pawn tried to move from " + pos1 + " to " + pos3 + " but was blocked by something");
Assert.IsFalse(pawn2.Offset(Point.Left), "Pawn moved from " + pos2 + " to " + pos3 + " when it should've been blocked");
Assert.AreEqual(pos3, pawn1.Position, "Pawn was not able to move from " + pos1 + " to " + pos3);
Assert.AreEqual(pos2, pawn2.Position, "Pawn was able to move from " + pos3 + " to " + pos2);
}
示例5: SolidPawnsMoveIntoEachOther
public void SolidPawnsMoveIntoEachOther()
{
Board board = new Board(BoardCommon.GRID_12X8);
Point pos1 = new Point(6, 4);
Point pos2 = new Point(7, 4);
Pawn pawn1 = new Pawn("First", board, pos1, null, true, true, true);
Pawn pawn2 = new Pawn("Second", board, pos2, null, true, true, true);
board.AddPawn(pawn1);
board.AddPawn(pawn2);
Assert.IsFalse(pawn1.Offset(Point.Right));
Assert.IsFalse(pawn2.Offset(Point.Left));
Assert.AreEqual(pos1, pawn1.Position);
Assert.AreEqual(pos2, pawn2.Position);
}