本文整理汇总了C#中GameBoard.CreateGameBlock方法的典型用法代码示例。如果您正苦于以下问题:C# GameBoard.CreateGameBlock方法的具体用法?C# GameBoard.CreateGameBlock怎么用?C# GameBoard.CreateGameBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameBoard
的用法示例。
在下文中一共展示了GameBoard.CreateGameBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChecksApplyMultipleMoves
public void ChecksApplyMultipleMoves()
{
GameBoard gameBoard = new GameBoard(3, 3);
GameBlockPlayer player1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
GameBlockMultipleMoves gameBlockMultiple =
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2, numberOfMultipleMoves: 2) as GameBlockMultipleMoves;
GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
GameBlockPlayer player2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2) as GameBlockPlayer;
gameBlockNormal1.SetAvailability(true);
gameBlockNormal2.SetAvailability(true);
gameBlockMultiple.NumberOfMovesApplied = 0;
player1.AvailableMoves = 2;
player2.AvailableMoves = 2;
BlockMovement move1 = new BlockMovement(player1, MovementDirection.Right);
BlockMovement move2 = new BlockMovement(player2, MovementDirection.Up);
bool applyMove1 = player1.ApplyMove(null, MovementDirection.Right, move1);
bool applyMove2 = player2.ApplyMove(null, MovementDirection.Up, move2);
Assert.IsTrue(applyMove1);
Assert.IsTrue(applyMove2);
}
示例2: ChecksApplyMoveWithLoopedChangeDirection2
public void ChecksApplyMoveWithLoopedChangeDirection2()
{
GameBoard gameBoard = new GameBoard(1, 4);
GameBlockPlayer player = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 1, MovementDirection.Right);
GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 3, MovementDirection.Left);
gameBlockNormal1.SetAvailability(true);
player.AvailableMoves = 2;
BlockMovement move = new BlockMovement(player, MovementDirection.Right);
bool applyMove = player.ApplyMove(null, MovementDirection.Right, move);
Assert.IsFalse(applyMove);
}
示例3: CorrectlyChecksOrphanedGameBoard
public void CorrectlyChecksOrphanedGameBoard()
{
GameBoard gameBoard = new GameBoard(3, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 2);
GameBlockNormal gameBlock = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1) as GameBlockNormal;
gameBlock.SetAvailability(true);
Assert.IsTrue(gameBoard.HasOrphan());
}
示例4: SolveTwoMultiBlock
public void SolveTwoMultiBlock()
{
/***************************
* N = null
* P = player
* M = multiple game block
* 0 1
* 0 P P
* 1 P M
* 2 P M
* 3 P P
*
***************************/
GameBoard gameBoard = new GameBoard(4, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 1, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 2, 1);
bool aborted;
List<GameBoard> solutions = GameBoardReverseSolver.ReverseSolve(gameBoard, 2, 20, 0, 60000, out aborted);
Assert.AreEqual(8, solutions.Count);
foreach (GameBoard solution in solutions)
{
Console.WriteLine("Game board: Difficulty={0} \n{1}\n", solution.GetDifficulty(), solution.GetBoardString());
Console.WriteLine("Solution: \n{0}\n", solution.GetSolutionString());
Assert.IsTrue(solution.IsUntouchedPuzzle());
Assert.IsTrue(solution.PlaySolution());
}
Console.WriteLine("Number of Solutions: {0}", solutions.Count);
}
示例5: SolveTrivialBoardWithMultipleMoves
public void SolveTrivialBoardWithMultipleMoves()
{
GameBoard gameBoard = new GameBoard(1, 4);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 3);
bool aborted;
List<GameBoard> solutions = GameBoardReverseSolver.ReverseSolve(gameBoard, 2, 1, 0, 60000, out aborted);
Assert.AreEqual(1, solutions.Count);
foreach (GameBoard solution in solutions)
{
Console.WriteLine("Game board: Difficulty={0} \n{1}\n", solution.GetDifficulty(), solution.GetBoardString());
Console.WriteLine("Solution: \n{0}\n", solution.GetSolutionString());
Assert.IsTrue(solution.IsUntouchedPuzzle());
Assert.IsTrue(solution.PlaySolution());
}
Console.WriteLine("Number of Solutions: {0}", solutions.Count);
}
示例6: SolveSmallPuzzle
public void SolveSmallPuzzle()
{
/***************************
* N = null
* P = player
* G = normal game block
* 0 1 2 3
* 0 N P N N
* 1 P G G P
* 2 N G N N
* 3 N G G P
* 4 N P G G
*
***************************/
GameBoard gameBoard = new GameBoard(5, 4);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 4, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 3, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 3, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 4, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 4, 3);
bool aborted;
List<GameBoard> solutions = GameBoardReverseSolver.ReverseSolve(gameBoard, 5, 10, 0, 60000, out aborted);
Assert.GreaterOrEqual(solutions.Count, 1);
Assert.LessOrEqual(solutions.Count, 10);
foreach (GameBoard solution in solutions)
{
Console.WriteLine("Game board: Difficulty={0} \n{1}\n", solution.GetDifficulty(), solution.GetBoardString());
Console.WriteLine("Solution: \n{0}\n", solution.GetSolutionString());
Assert.IsTrue(solution.IsUntouchedPuzzle());
Assert.IsTrue(solution.PlaySolution());
}
Console.WriteLine("Number of Solutions: {0}", solutions.Count);
}
示例7: SolveMiniWithMultiplePuzzleWithLoop
public void SolveMiniWithMultiplePuzzleWithLoop()
{
GameBoard gameBoard = new GameBoard(1, 4);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 3, MovementDirection.Left);
bool aborted;
List<GameBoard> solutions = GameBoardReverseSolver.ReverseSolve(gameBoard, 3, 10, 0, 60000, out aborted);
Assert.GreaterOrEqual(solutions.Count, 1);
foreach (GameBoard solution in solutions)
{
Console.WriteLine("Game board: Difficulty={0} \n{1}\n", solution.GetDifficulty(), solution.GetBoardString());
Console.WriteLine("Solution: \n{0}\n", solution.GetSolutionString());
Assert.IsTrue(solution.IsUntouchedPuzzle());
Assert.IsTrue(solution.PlaySolution());
}
Console.WriteLine("Number of Solutions: {0}", solutions.Count);
}
示例8: TestReverseIsTrueCorrectly
public void TestReverseIsTrueCorrectly()
{
GameBoard gameBoard = new GameBoard(1, 3);
GameBlockPlayer gameBlockPlayer = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
gameBlockNormal1.SetAvailability(false);
gameBlockNormal2.SetAvailability(false);
bool canReverseSolve = gameBoard.TestCanReverseSolve();
Assert.IsTrue(canReverseSolve);
}
示例9: ReverseMoveTwoOneGameBlock
public void ReverseMoveTwoOneGameBlock(
int nothing,
MovementDirection direction,
bool shouldBeApplied,
int startingPointAvailableMoves,
int endingPointAvailableMoves,
bool[] startingAvailable,
bool[] endingAvaialble,
bool useTopStartingBlock)
{
GameBoard gameBoard = new GameBoard();
gameBoard.GameBlocks = new IGameBlock[4,1];
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 0);
GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 0) as GameBlockNormal;
GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 0) as GameBlockNormal;
gameBlockNormal1.SetAvailability(startingAvailable[0]);
gameBlockNormal2.SetAvailability(startingAvailable[1]);
GameBlockNormal gameBlockNormal = useTopStartingBlock ? gameBlockNormal1 : gameBlockNormal2;
BlockMovement movement;
bool applied = gameBlockNormal.ApplyReverseMove(
null, direction, startingPointAvailableMoves, out movement, null, null, new Queue<IGameBlock>());
Assert.AreEqual(shouldBeApplied, applied);
Assert.AreEqual(endingAvaialble[0], gameBlockNormal1.IsAvailable);
Assert.AreEqual(endingAvaialble[1], gameBlockNormal2.IsAvailable);
if (shouldBeApplied)
{
Assert.AreEqual(endingPointAvailableMoves, movement.SourceBlock.AvailableMoves);
}
}
示例10: ForceChangeDirectionCorrectly
public void ForceChangeDirectionCorrectly(
MovementDirection forceDirection,
int playerRow,
int playerColumn,
MovementDirection playerMovementDirection,
int[] filledX,
int[] filledY,
bool moveGetsApplied)
{
GameBoard gameBoard = new GameBoard(5, 5);
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2) as IGameBlockParent).AvailableMoves = 2;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0) as IGameBlockParent).AvailableMoves = 2;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 4) as IGameBlockParent).AvailableMoves = 2;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 4, 2) as IGameBlockParent).AvailableMoves = 2;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as IGameBlockDestination).SetAvailability(true);
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1) as IGameBlockDestination).SetAvailability(true);
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 3) as IGameBlockDestination).SetAvailability(true);
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 3, 2) as IGameBlockDestination).SetAvailability(true);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 2, 2, forceDirection);
IGameBlockParent gameBlockParent = gameBoard.GameBlocks[playerRow, playerColumn] as IGameBlockParent;
BlockMovement move = new BlockMovement(gameBlockParent, playerMovementDirection);
bool moveApplied = gameBlockParent.ApplyMove(null, playerMovementDirection, move);
Assert.AreEqual(moveGetsApplied, moveApplied);
for (int i = 0; i < filledX.Length; i++)
{
IGameBlockDestination gameBlock = gameBoard.GameBlocks[filledX[i], filledY[i]] as IGameBlockDestination;
Assert.IsFalse(gameBlock.IsAvailable);
}
}
示例11: DeniesMoveWithExtraBlockWithNotEnoughBlocks
public void DeniesMoveWithExtraBlockWithNotEnoughBlocks()
{
GameBoard gameBoard = new GameBoard(1, 3);
GameBlockPlayer gameBlockPlayer = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
GameBlockExtraMove gameBlockExtraMove = gameBoard.CreateGameBlock(GameBoard.GameBlockType.ExtraMove, 0, 1) as GameBlockExtraMove;
GameBlockNormal gameBlockNormal = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
gameBlockPlayer.AvailableMoves = 1;
gameBlockNormal.SetAvailability(true);
BlockMovement move = new BlockMovement(gameBlockPlayer, MovementDirection.Right);
Assert.IsFalse(gameBlockPlayer.ApplyMove(null, MovementDirection.Right, move));
Assert.IsTrue(gameBlockNormal.IsAvailable);
}
示例12: CorrectlyMovesWithExtraBlock
public void CorrectlyMovesWithExtraBlock()
{
GameBoard gameBoard = new GameBoard(1, 4);
GameBlockPlayer gameBlockPlayer = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
GameBlockExtraMove gameBlockExtraMove = gameBoard.CreateGameBlock(GameBoard.GameBlockType.ExtraMove, 0, 1) as GameBlockExtraMove;
GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 3) as GameBlockNormal;
gameBlockPlayer.AvailableMoves = 1;
gameBlockNormal1.SetAvailability(true);
gameBlockNormal2.SetAvailability(true);
BlockMovement move = new BlockMovement(gameBlockPlayer, MovementDirection.Right);
Assert.IsTrue(gameBlockPlayer.ApplyMove(null, MovementDirection.Right, move));
Assert.IsFalse(gameBlockNormal1.IsAvailable);
Assert.IsFalse(gameBlockNormal2.IsAvailable);
}
示例13: CorrectlyChecksUnsolvedGameBoard
public void CorrectlyChecksUnsolvedGameBoard()
{
GameBoard gameBoard = new GameBoard(4, 4);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2);
GameBlockNormal gameBlockNormal21 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1) as GameBlockNormal;
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 2);
gameBlockNormal21.SetAvailability(true);
Assert.IsTrue(!gameBoard.IsSolved());
}
示例14: CorrectlyChecksSolvedGameBoard
public void CorrectlyChecksSolvedGameBoard()
{
GameBoard gameBoard = new GameBoard(4, 4);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 0);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 3);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1);
gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 2);
Assert.IsTrue(gameBoard.IsSolved());
}
示例15: CorrectlyChecksOrphanedGameBoardWithGameBlockPlayers
public void CorrectlyChecksOrphanedGameBoardWithGameBlockPlayers()
{
GameBoard gameBoard = new GameBoard(3, 3);
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 2) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 1) as GameBlockPlayer).AvailableMoves = 1;
(gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2) as GameBlockPlayer).AvailableMoves = 1;
GameBlockNormal gameBlock = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1) as GameBlockNormal;
gameBlock.SetAvailability(true);
Assert.IsTrue(gameBoard.HasOrphan());
}