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


C# Game.Play方法代码示例

本文整理汇总了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();
        }
开发者ID:dpollock,项目名称:week-9-day-3,代码行数:8,代码来源:Program.cs

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

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

示例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]);
        }
开发者ID:HerrLoesch,项目名称:Katas,代码行数:11,代码来源:GameOfLifeTests.cs

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

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

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

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

示例9: Main

 static void Main(string[] args)
 {
     Game game = new Game(2, 3, OutputType.File);
     game.Play();
 }
开发者ID:sauravMSFT,项目名称:TicTacToe-OOP,代码行数:5,代码来源:GameManager.cs

示例10: Main

    public static void Main()
    {
        var game = new Game(3);

        game.Play();
    }
开发者ID:fazueu,项目名称:aspnet-vnext-samples,代码行数:6,代码来源:Program.cs

示例11: Play_ScissorsRock_P2

 public void Play_ScissorsRock_P2()
 {
     Game g = new Game("Scissors", "Rock");
       Assert.Equal("Player 2", g.Play());
 }
开发者ID:CallanMcNulty,项目名称:rock-paper-scissors,代码行数:5,代码来源:Game_tests.cs

示例12: Play_RockRock_Draw

 public void Play_RockRock_Draw()
 {
     Game g = new Game("Rock", "Rock");
       Assert.Equal("Draw", g.Play());
 }
开发者ID:CallanMcNulty,项目名称:rock-paper-scissors,代码行数:5,代码来源:Game_tests.cs

示例13: Play_RockPaper_P2

 public void Play_RockPaper_P2()
 {
     Game g = new Game("Rock", "Paper");
       Assert.Equal("Player 2", g.Play());
 }
开发者ID:CallanMcNulty,项目名称:rock-paper-scissors,代码行数:5,代码来源:Game_tests.cs

示例14: Play_PaperScissors_P2

 public void Play_PaperScissors_P2()
 {
     Game g = new Game("Paper", "Scissors");
       Assert.Equal("Player 2", g.Play());
 }
开发者ID:CallanMcNulty,项目名称:rock-paper-scissors,代码行数:5,代码来源:Game_tests.cs

示例15: Play_PaperRock_P1

 public void Play_PaperRock_P1()
 {
     Game g = new Game("Paper", "Rock");
       Assert.Equal("Player 1", g.Play());
 }
开发者ID:CallanMcNulty,项目名称:rock-paper-scissors,代码行数:5,代码来源:Game_tests.cs


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