本文整理汇总了C#中Game.Play方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Play方法的具体用法?C# Game.Play怎么用?C# Game.Play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var g = new Game(new ConsoleInputHandler(),
new ConsoleGameRender(),
new TextMapLoader(@"C:\IronYard\sokoban_levels.txt"));
g.Play();
}
示例2: Main
static void Main(string[] args)
{
var robotWarsGame = new Game(new ConsoleWriter());
var commandParsers = new List<CommandParser>()
{
new CreateBattleArenaCommandParser(robotWarsGame, new BattleArenaFactory()),
new DeployRobotCommandParser(robotWarsGame, new RobotFactory()),
new MoveRobotCommandParser(robotWarsGame, new MoveInstructionFactory(new LinearMoveFactory()))
};
bool startGame = false;
while(!startGame)
{
var consoleInput = System.Console.ReadLine();
if(ProgramShouldQuit(consoleInput))
{
return;
}
try
{
commandParsers.ForEach(commandParser =>
{
if(commandParser.Validate(consoleInput))
{
commandParser.ProcessInput(consoleInput);
}
});
}
catch(Exception exception)
{
System.Console.WriteLine(exception.Message);
}
if(robotWarsGame.IsReadyToStart())
{
System.Console.Write("Ready to go to war (y/n)? ");
consoleInput = System.Console.ReadLine();
if(GameShouldStart(robotWarsGame, consoleInput))
{
startGame = true;
}
}
}
try
{
robotWarsGame.Play();
}
catch(Exception exception)
{
System.Console.WriteLine(exception.Message);
}
System.Console.ReadLine();
}
示例3: Play_6_Moves
public void Play_6_Moves()
{
var game = new Game();
var moves = game.Play(6);
foreach (var move in moves)
{
Console.WriteLine(move);
}
VerifyEnd(game, "ABCDEF");
}
示例4: Any_live_cell_with_fewer_than_two_live_neighbours_dies
public void Any_live_cell_with_fewer_than_two_live_neighbours_dies()
{
var sut = new Game();
var source = new bool[3,3];
source[1, 1] = true;
source = sut.Play(source);
Assert.AreEqual(false, source[1,1]);
}
示例5: Any_dead_cell_with_exactly_two_live_neighbours_is_still_dead
public void Any_dead_cell_with_exactly_two_live_neighbours_is_still_dead()
{
var sut = new Game();
var source = new bool[3, 3];
source[1, 1] = false;
source[0, 2] = true;
source[2, 1] = true;
source = sut.Play(source);
Assert.AreEqual(false, source[1, 1]);
}
示例6: Any_dead_cell_with_exactly_three_live_neighbours_becomes_a_live_cell
public void Any_dead_cell_with_exactly_three_live_neighbours_becomes_a_live_cell()
{
var sut = new Game();
var source = new bool[3, 3];
source[1, 1] = false;
source[0, 2] = true;
source[2, 1] = true;
source[2, 2] = true;
source = sut.Play(source);
Assert.AreEqual(true, source[1, 1]);
}
示例7: TestGame
private static void TestGame(Random rand)
{
Console.WriteLine("# Test Game class");
Game game = new Game(rand, 4);
game.AddPlayer("Terence Hill");
game.AddPlayer(new Player("Bud Spencer"));
game.AddPlayer("Darth Vader");
game.AddPlayer("Anakin Skywalker");
game.AddPlayer("No More");
Console.WriteLine("------ WINNER ------");
Console.WriteLine(game.Play());
Console.WriteLine("------ GAME ------");
Console.WriteLine(game);
Console.WriteLine("------ Third Player Second Card ------");
Console.WriteLine(game[2][1]);
}
示例8: TestGame2
private static void TestGame2(Random rand)
{
Console.WriteLine("# Test Game class");
Game game = new Game(rand, "Terence Hill", "Bud Spencer", "Darth Vader", "Anakin Skywalker");
Console.WriteLine("------ WINNER ------");
Console.WriteLine(game.Play());
Console.WriteLine("------ GAME ------");
Console.WriteLine(game);
Console.WriteLine("------ Third Player Second Card ------");
Console.WriteLine(game[2][1]);
String[] names = new String[4];
names[0] = "Terence Hill";
names[3] = "Anakin Skywalker";
Game game2 = new Game(rand, names);
}
示例9: Main
static void Main(string[] args)
{
Game game = new Game(2, 3, OutputType.File);
game.Play();
}
示例10: Main
public static void Main()
{
var game = new Game(3);
game.Play();
}
示例11: Play_ScissorsRock_P2
public void Play_ScissorsRock_P2()
{
Game g = new Game("Scissors", "Rock");
Assert.Equal("Player 2", g.Play());
}
示例12: Play_RockRock_Draw
public void Play_RockRock_Draw()
{
Game g = new Game("Rock", "Rock");
Assert.Equal("Draw", g.Play());
}
示例13: Play_RockPaper_P2
public void Play_RockPaper_P2()
{
Game g = new Game("Rock", "Paper");
Assert.Equal("Player 2", g.Play());
}
示例14: Play_PaperScissors_P2
public void Play_PaperScissors_P2()
{
Game g = new Game("Paper", "Scissors");
Assert.Equal("Player 2", g.Play());
}
示例15: Play_PaperRock_P1
public void Play_PaperRock_P1()
{
Game g = new Game("Paper", "Rock");
Assert.Equal("Player 1", g.Play());
}