本文整理汇总了C#中Game.Tick方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Tick方法的具体用法?C# Game.Tick怎么用?C# Game.Tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Tick方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnyLiveCellWithFewerThanTwoLiveNeighboursDies
public void AnyLiveCellWithFewerThanTwoLiveNeighboursDies()
{
var game = new Game(3);
game.Tick();
Assert.False(game.NextLife[2, 0].IsAlive);
}
示例2: Main
public static void Main(string[] args)
{
System.Console.CursorVisible = false;
const int rows = 20;
const int columns = 20;
var savannah = new Savannah(rows, columns);
var game = new Game(savannah);
var visitor = new ConsoleVisitor();
while (true)
{
IEnumerable<Action> actions = game.Tick();
foreach (Action action in actions)
{
action();
}
System.Console.Clear();
game.Accept((ISavannahVisitor) visitor);
game.Accept((IAnimalVisitor) visitor);
Thread.Sleep(TimeSpan.FromMilliseconds(500));
}
}
示例3: AnyDeadCellWithExactlyThreeLiveNeighboursBecomesAlive
public void AnyDeadCellWithExactlyThreeLiveNeighboursBecomesAlive()
{
var game = new Game(3);
game.BringCellToLifeAt(0, 0);
game.BringCellToLifeAt(0, 1);
game.BringCellToLifeAt(1, 1);
game.Tick();
Assert.True(game.NextLife[1, 0].IsAlive);
}
示例4: AnyLiveCellWithTwoOrThreeThreeLiveNeighboursLivesOn
public void AnyLiveCellWithTwoOrThreeThreeLiveNeighboursLivesOn()
{
var game = new Game(3);
game.BringCellToLifeAt(0, 0);
game.BringCellToLifeAt(0, 1);
game.BringCellToLifeAt(1, 1);
game.Tick();
Assert.True(game.NextLife[0, 0].IsAlive);
Assert.True(game.NextLife[0, 1].IsAlive);
Assert.True(game.NextLife[1, 1].IsAlive);
}
示例5: AnyLiveCellWithMoreThanThreeLiveNeighboursDies
public void AnyLiveCellWithMoreThanThreeLiveNeighboursDies()
{
var game = new Game(3);
game.BringCellToLifeAt(0, 1);
game.BringCellToLifeAt(0, 2);
game.BringCellToLifeAt(1, 0);
game.BringCellToLifeAt(1, 1);
game.BringCellToLifeAt(1, 2);
game.Tick();
Assert.False(game.NextLife[1, 1].IsAlive);
}
示例6: ToCreateANewPiece_ThePieceGeneratorIsUsed
public void ToCreateANewPiece_ThePieceGeneratorIsUsed()
{
var pieceGeneratorMock = new Mock<IPieceGenerator>();
var myPiece = new Piece(Shape.Arrow, Color.Bisque);
pieceGeneratorMock.Setup(pg => pg.GetNewPiece())
.Returns(() => myPiece);
var game = new Game(pieceGeneratorMock.Object);
game.Start();
// Act
game.Tick(); // This is the first tick in that new game. According to the AutomaticBehaviour.feature this creates a new piece
pieceGeneratorMock.Verify(pg => pg.GetNewPiece(), Times.Once());
game.CurrentPiece.Shape.Should().Be(myPiece.Shape);
game.CurrentPiece.Color.Should().Be(myPiece.Color);
}
示例7: Main
static void Main()
{
Console.WriteLine("Game of life. Any key to exit.");
var game = new Game(new Grid(5, 5, new[]
{
new Tuple<int, int>(1, 3),
new Tuple<int, int>(2, 3),
new Tuple<int, int>(3, 3)
}));
while(true)
{
// todo: make this work and change in place!
Console.Write("\r{0}", game.DisplayGrid());
game.Tick();
Thread.Sleep(500);
if (Console.ReadLine() != null)
break;
}
}
示例8: Execute
public override void Execute(Game game, IMessageLog log)
{
game.Tick(log);
}