当前位置: 首页>>代码示例>>C#>>正文


C# Game.Tick方法代码示例

本文整理汇总了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);
        }
开发者ID:hemantksingh,项目名称:GameOfLife,代码行数:7,代码来源:GameTests.cs

示例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));
            }
        }
开发者ID:jbfp,项目名称:SavannahGame,代码行数:25,代码来源:Program.cs

示例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);
        }
开发者ID:hemantksingh,项目名称:GameOfLife,代码行数:10,代码来源:GameTests.cs

示例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);
        }
开发者ID:hemantksingh,项目名称:GameOfLife,代码行数:13,代码来源:GameTests.cs

示例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);
        }
开发者ID:hemantksingh,项目名称:GameOfLife,代码行数:14,代码来源:GameTests.cs

示例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);
        }
开发者ID:paulroho,项目名称:Tetris,代码行数:16,代码来源:GameTests.cs

示例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;
            }
        }
开发者ID:ascjones,项目名称:GameOfLife,代码行数:23,代码来源:Program.cs

示例8: Execute

 public override void Execute(Game game, IMessageLog log)
 {
     game.Tick(log);
 }
开发者ID:paulbatum,项目名称:PushFrenzy,代码行数:4,代码来源:TimerTickCommand.cs


注:本文中的Game.Tick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。