本文整理汇总了C#中IRenderable.Write方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderable.Write方法的具体用法?C# IRenderable.Write怎么用?C# IRenderable.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderable
的用法示例。
在下文中一共展示了IRenderable.Write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameEngine
/// <summary>
/// Prevents a default instance of the <see cref="GameEngine" /> class from being created.
/// Part of Singleton.
/// Starts the game if there are no errors.
/// </summary>
private GameEngine(IRenderable renderer)
{
try
{
this.StartNewGame(renderer);
}
catch (ArgumentOutOfRangeException ex)
{
renderer.Write(ex.Message);
}
}
示例2: BeginGame
/// <summary>
/// Method that is responsible for communication between the user and the engine.
/// Handles user input and outputs game response.
/// </summary>
private void BeginGame(IRenderable render)
{
ScoreBoard scoreBoard = new ScoreBoard();
render.PrintField(this.gameField.GetFieldNumbers());
bool gameIsFinished = false;
int moves = 0;
string inputCommand = render.Read("give me command: ").Trim();
while (inputCommand != "exit")
{
switch (inputCommand)
{
case "top":
render.PrintScoreboard(scoreBoard.Scores());
break;
case "restart":
this.StartNewGame(render, true);
break;
default:
moves = MoveNumberIfValid(render, moves, inputCommand);
break;
}
render.PrintField(this.gameField.GetFieldNumbers());
gameIsFinished = this.gameField.IsSolved();
if (gameIsFinished)
{
string message = string.Format("Congratulations! You won the game in {0} moves.", moves);
render.Write(message);
this.AddUserToScoreBoard(scoreBoard, moves, render);
moves = 0;
this.StartNewGame(render);
}
inputCommand = render.Read("give me command: ").Trim();
}
}
示例3: MoveNumberIfValid
private int MoveNumberIfValid(IRenderable render, int moves, string inputCommand)
{
if (this.IsNumberMovable(inputCommand))
{
this.MoveNumber(int.Parse(inputCommand));
moves++;
}
else
{
render.Write("Invalid Command");
}
return moves;
}