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


C# Playfield类代码示例

本文整理汇总了C#中Playfield的典型用法代码示例。如果您正苦于以下问题:C# Playfield类的具体用法?C# Playfield怎么用?C# Playfield使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Playfield类属于命名空间,在下文中一共展示了Playfield类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrintTable

        public static void PrintTable(Playfield playfield)
        {
            string columnHeader = "    ";
            for (int i = 0; i < playfield.Width; i++)
            {
                columnHeader += i.ToString().PadLeft(3);
            }

            Console.WriteLine(columnHeader);

            Console.WriteLine("    " + new String('-', playfield.Width * 3));

            for (int row = 0; row < playfield.Height; row++)
            {
                Console.Write(row.ToString().PadLeft(2) + " | ");
                for (int col = 0; col < playfield.Width; col++)
                {
                    Console.Write(playfield.Field[row, col].ToString().PadLeft(2) + " ");
                }

                Console.WriteLine("| ");
            }

            Console.WriteLine("    " + new String('-', playfield.Width * 3));
        }
开发者ID:TishoAngelov,项目名称:TelerikAcademy,代码行数:25,代码来源:ConsoleIOFacade.cs

示例2: TestRenderFieldGrid_PlayerAtStartPosition

        public void TestRenderFieldGrid_PlayerAtStartPosition()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 0, 1, 1},
                            {1, 1, 1, 0, 0, 0, 1},
                            {0, 0, 0, 0, 1, 0, 0},
                            {1, 0, 1, 0, 1, 1, 1},
                            {1, 0, 0, 1, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {1, 0, 0, 1, 0, 1, 0}
                        };
            Playfield playfield = new Playfield(labyrinthGrid);

            string actualOutput = Renderer.RenderField(playfield.LabyrinthGrid,
                                                       playfield.PlayerPosition.Row, playfield.PlayerPosition.Col);

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendLine("--XX-XX");
            expectedOutput.AppendLine("XXX---X");
            expectedOutput.AppendLine("----X--");
            expectedOutput.AppendLine("X-X*XXX");
            expectedOutput.AppendLine("X--X---");
            expectedOutput.AppendLine("X-X--XX");
            expectedOutput.AppendLine("X--X-X-");

            bool areEqual = actualOutput == expectedOutput.ToString();
            Assert.IsTrue(areEqual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:29,代码来源:RendererTests.cs

示例3: TestIsValidMove_CanMoveDown

        public void TestIsValidMove_CanMoveDown()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 1, 1, 0, 1, 1, 1},
                            {0, 0, 0, 0, 0, 0, 1},
                            {1, 0, 1, 0, 1, 0, 1},
                            {1, 0, 1, 0, 1, 0, 0},
                            {0, 1, 1, 1, 1, 1, 0},
                            {0, 0, 1, 0, 0, 0, 1},
                            {1, 0, 0, 0, 0, 0, 0}
                        };

            Playfield playfield = new Playfield(labyrinthGrid);

            //Moving playerPosition at row=5 and col=2
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Down);

            Direction directionDown = Direction.Down;
            bool expected = true;
            bool actual = MovesChecker.IsValidMove(playfield, directionDown);
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:27,代码来源:MovesCheckerTests.cs

示例4: TestGetTopResults

        public void TestGetTopResults()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);

            string expected = engine.GetTopResults();
            string actual = new ScoreBoard().ShowScoreboard();
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:9,代码来源:GameEngineTests.cs

示例5: TestInitializeField_IsCorrectStartPosition

        public void TestInitializeField_IsCorrectStartPosition()
        {
            Playfield playfield = new Playfield();
            playfield.InitializeField();

            Position expected = new Position(3, 3);
            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:10,代码来源:PlayfieldTests.cs

示例6: TestProcessInput_OnWriteRestart

        public void TestProcessInput_OnWriteRestart()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("restart");

            int expected = 0;
            int actual = engine.Score;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:ConsoleInputTests.cs

示例7: TestProcessInput_OnWriteExit

        public void TestProcessInput_OnWriteExit()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("exit");

            bool expected = true;
            bool actual = engine.HasGameQuit;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:ConsoleInputTests.cs

示例8: TestMoveAtDirection_MoveAtUp

        public void TestMoveAtDirection_MoveAtUp()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            engine.MoveAtDirection(Direction.Up, engine.MoveUp);

            Position expected = new Position(2, 3);
            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:GameEngineTests.cs

示例9: TestInitializeNewGame_ScoreIsUpdated

        public void TestInitializeNewGame_ScoreIsUpdated()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            engine.MoveAtDirection(Direction.Down, engine.MoveDown);
            engine.InitializeNewGame();

            int expected = 0;
            int actual = engine.Score;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:GameEngineTests.cs

示例10: TestProcessInput_OnWriteR

        public void TestProcessInput_OnWriteR()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("R");

            Position expected = new Position(3, 4);
            Position actual = playfield.PlayerPosition;

            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:13,代码来源:ConsoleInputTests.cs

示例11: TestInitializeField_IsClearPlayerPosition

        public void TestInitializeField_IsClearPlayerPosition()
        {
            Playfield playfield = new Playfield();
            playfield.InitializeField();

            int expectedRow = 3;
            int expectedCol = 3;
            int actualRow = playfield.PlayerPosition.Row;
            int actualCol = playfield.PlayerPosition.Col;

            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expectedRow, actualRow);
            Assert.AreEqual(expectedCol, actualCol);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:14,代码来源:PlayfieldTests.cs

示例12: TestIsVictory_NorthEastCornerExit

        public void TestIsVictory_NorthEastCornerExit()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 1, 1, 0},
                            {1, 1, 1, 1, 0, 0, 1},
                            {0, 0, 0, 1, 0, 1, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {0, 1, 0, 1, 1, 0, 0},
                            {0, 0, 1, 0, 0, 0, 0},
                            {0, 0, 1, 0, 1, 0, 0}
                        };
            Position customPosition = new Position(0, 6);
            Playfield playfield = new Playfield(labyrinthGrid, customPosition);

            bool expected = true;
            bool actual = playfield.IsVictory();
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:19,代码来源:PlayfieldTests.cs

示例13: TestIsValidMove_CanMoveRight

        public void TestIsValidMove_CanMoveRight()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 1, 1, 1},
                            {1, 1, 1, 1, 1, 1, 1},
                            {0, 0, 0, 0, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {0, 1, 0, 1, 0, 0, 0},
                            {0, 0, 1, 0, 0, 0, 0},
                            {0, 0, 0, 0, 0, 0, 0}
                        };

            Playfield playfield = new Playfield(labyrinthGrid);
            Direction directionRight = Direction.Right;

            bool expected = true;
            bool actual = MovesChecker.IsValidMove(playfield, directionRight);
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:20,代码来源:MovesCheckerTests.cs

示例14: TestRenderFieldGrid_PlayerAtOtherPosition

        public void TestRenderFieldGrid_PlayerAtOtherPosition()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 0, 1, 1},
                            {1, 1, 1, 0, 0, 0, 1},
                            {0, 0, 0, 0, 1, 0, 0},
                            {1, 0, 1, 0, 1, 1, 1},
                            {1, 0, 0, 1, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {1, 0, 0, 1, 0, 1, 0}
                        };
            Playfield playfield = new Playfield(labyrinthGrid);

            //Moving playerPosition at row=2 and col=6 (start index=0)
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Down);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);

            string actualOutput = Renderer.RenderField(playfield.LabyrinthGrid,
                                                       playfield.PlayerPosition.Row, playfield.PlayerPosition.Col);

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendLine("--XX-XX");
            expectedOutput.AppendLine("XXX---X");
            expectedOutput.AppendLine("----X-*");
            expectedOutput.AppendLine("X-X-XXX");
            expectedOutput.AppendLine("X--X---");
            expectedOutput.AppendLine("X-X--XX");
            expectedOutput.AppendLine("X--X-X-");

            bool areEqual = actualOutput == expectedOutput.ToString();
            Assert.IsTrue(areEqual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:37,代码来源:RendererTests.cs

示例15: CreatePlayfield

 /// <summary>
 /// Creates the playfield matrix with the balloons in it
 /// </summary>
 public override Playfield CreatePlayfield()
 {
     var largePlayfield = new Playfield(Width, Height);
     return largePlayfield;
 }
开发者ID:Teamwork-Balloons-Pop-5,项目名称:Balloons-Pop,代码行数:8,代码来源:LargePlayfieldCreator.cs


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