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


C# GameBoard类代码示例

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


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

示例1: ChecksApplyMultipleMoves

        public void ChecksApplyMultipleMoves()
        {
            GameBoard gameBoard = new GameBoard(3, 3);

            GameBlockPlayer player1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
            GameBlockMultipleMoves gameBlockMultiple =
                gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2, numberOfMultipleMoves: 2) as GameBlockMultipleMoves;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
            GameBlockPlayer player2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2) as GameBlockPlayer;

            gameBlockNormal1.SetAvailability(true);
            gameBlockNormal2.SetAvailability(true);
            gameBlockMultiple.NumberOfMovesApplied = 0;

            player1.AvailableMoves = 2;
            player2.AvailableMoves = 2;
            BlockMovement move1 = new BlockMovement(player1, MovementDirection.Right);
            BlockMovement move2 = new BlockMovement(player2, MovementDirection.Up);
            bool applyMove1 = player1.ApplyMove(null, MovementDirection.Right, move1);
            bool applyMove2 = player2.ApplyMove(null, MovementDirection.Up, move2);

            Assert.IsTrue(applyMove1);
            Assert.IsTrue(applyMove2);
        }
开发者ID:ttat,项目名称:puzzlewarrior,代码行数:25,代码来源:DataModelTests.cs

示例2: baseResult

        private GameBoard baseResult(GameBoard board)
        {
            int bestScore = int.MinValue;
            GameBoard output = board;

            for (int x = 0; x < 8; ++x)
            {
                for (int y = 0; y < 8; ++y)
                {
                    if (!board.canPlayAtPosition(x, y))
                        continue;

                    GameBoard playBoard = board.makeMove(x, y);
                    int score = evaluateBoard(board.currentTurn, playBoard);

                    if (score > bestScore)
                    {
                        bestScore = score;
                        output = playBoard;
                    }
                }
            }

            return output;
        }
开发者ID:rodya-mirov,项目名称:Othello,代码行数:25,代码来源:NPlyAI.cs

示例3: GetAllMovesFromField

        public static IEnumerable<IMove> GetAllMovesFromField(GameBoard board, BoardPosition fromFieldPosition, out bool forcedOnly)
        {
            PlayerColor player = board[fromFieldPosition].Occupation;
            List<IMove> moves = new List<IMove>();

            var firstTargets = GetPossibleTargetFields(board, fromFieldPosition, out forcedOnly);

            if (!forcedOnly)
            {
                moves.AddRange(firstTargets.Select(pos => new SimpleMove(player, fromFieldPosition, pos, board[fromFieldPosition].Piece == PieceType.King, false)));
                return moves;
            }

            JumpTree tree = new JumpTree(fromFieldPosition, firstTargets, board);
            ConstructJumpTree(ref tree);

            var paths = tree.Linearize();
            tree = null;

            foreach (var path in paths)
            {
                if (path.Count == 2)
                {
                    moves.Add(new SimpleMove(player, path[0], path[1], board[fromFieldPosition].Piece == PieceType.King, true));
                }
                else
                {
                    CompoundMove move = CompoundMove.FromPositions(player, path.First(), path.Last(), board[fromFieldPosition].Piece == PieceType.King, path.GetRange(1, path.Count - 2).ToArray());
                    moves.Add(move);
                }
            }

            return moves;
        }
开发者ID:Chronix,项目名称:GothicCheckers,代码行数:34,代码来源:RuleEngine.cs

示例4: Generate

 /// <summary>
 /// Generates a grid specified by user
 /// </summary>
 /// <param name="sender">Button Click, not used.</param>
 /// <param name="e">Button Click, not used.</param>
 protected void Generate(object sender, EventArgs e)
 {
     int r, c;
     //Try to convert the text in text boxes to ints
     try
     {
         r = Convert.ToInt32(entryRows.Text);
         c = Convert.ToInt32(entryCols.Text);
     }
     //if it fails, log it, but dont close. Maybe user just mistyped.
     catch (FormatException ex)
     {
         Console.WriteLine(ex.ToString());
         return;
     }
     if (CheckBounds(r, c))
     {
         board = new GameBoard(r, c);
         GridConstructor gc = new GridConstructor(r, c, this);
         gc.Show();
         gc.SetGrid();
     }
     else
     {
         //if bounds check is not met, then display a specific dialog.
         ErrorDialog error = new ErrorDialog(2);
         error.Show();
     }
 }
开发者ID:BrianAllred,项目名称:AkariSolver,代码行数:34,代码来源:MainWindow.cs

示例5: CheckForGameEnd

        public static bool CheckForGameEnd(GameBoard board, out PlayerColor winner)
        {
            int whitePieces = board.GetPieceCountByOccupation(PlayerColor.White);
            int blackPieces = board.GetPieceCountByOccupation(PlayerColor.Black);

            if (whitePieces == 0)
            {
                winner = PlayerColor.Black;
                return true;
            }
            else if (blackPieces == 0)
            {
                winner = PlayerColor.White;
                return true;
            }
            else if (board.IdleMoves >= MAX_IDLE_MOVES)
            {
                if (whitePieces == blackPieces)
                {
                    winner = PlayerColor.None;
                    return true;
                }

                winner = whitePieces > blackPieces ? PlayerColor.White : PlayerColor.Black;
                return true;
            }

            winner = PlayerColor.None;
            return false;
        }
开发者ID:Chronix,项目名称:GothicCheckers,代码行数:30,代码来源:RuleEngine.cs

示例6: GetAllMovesForPlayer

        public static IEnumerable<IMove> GetAllMovesForPlayer(GameBoard board, PlayerColor player)
        {
            IEnumerable<GameField> fields = board.GetFieldsByPlayer(player);
            List<IMove> forcedMoves = new List<IMove>();
            List<IMove> idleMoves = new List<IMove>();

            bool forcedOnly;

            foreach (GameField f in fields)
            {
                var moves = GetAllMovesFromField(board, f.Position, out forcedOnly);

                if (forcedOnly) forcedMoves.AddRange(moves);
                else idleMoves.AddRange(moves);
            }

            if (forcedMoves.Count > 0)
            {
                int longest = 0;

                forcedMoves.ForEach(mv => { if (mv.Length > longest) longest = mv.Length; });
                return forcedMoves.Where(mv => mv.Length == longest).ForEach<IMove, GameBoard>(SetMoveCaptures, board);
            }

            return idleMoves;
        }
开发者ID:Chronix,项目名称:GothicCheckers,代码行数:26,代码来源:RuleEngine.cs

示例7: Initialize

        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();

            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);

            zTime = new ZombieTime(board);

            nurseryOne = new Nursery(board, darwin);
            nurseryTwo = new Nursery(board, darwin);

            fatBossZombie = new FatBossZombie(15, 4, 19, 14, 4, 3, darwin, board);
            fatBossZombie.resetGapeMode();
            stairs = new Stairs(board);

            walls = setWallsInLevelSix();

            setLevelState();
            gameState.setState(GameState.state.Start);
        }
开发者ID:gkericks,项目名称:legend-of-darwin,代码行数:28,代码来源:Level6.cs

示例8: Main

        static void Main(string[] args)
        {
            GameBoard newGameBoard = new GameBoard();
            WordsForGame words = new WordsForGame();
            _answer = words.wordGenerator();
            _blankAnswer = words.blankWord(_answer);

            //debug
            //Console.WriteLine(_answer);

            while(_blankCount > 0 && _playerLives >= 0)
            {
                newGameBoard.drawGallows(_playerLives);
                Console.WriteLine(_blankAnswer);
                Console.WriteLine("\nEnter a letter to guess");
                guess = Console.ReadKey().KeyChar;
                words.checkGuessAgainstWord(_answer, _blankAnswer, guess);
                
                Console.Clear();
            }

            if (_blankCount == 0)
            {
                Console.WriteLine("Hooray, you win");
            }
            
            else
            {
                Console.WriteLine("Something has gone horribly wrong");
            }

            Console.ReadLine();
        }
开发者ID:JesterMalone,项目名称:CSIS2450,代码行数:33,代码来源:Program.cs

示例9: TestThatAllBobsDiesAtEndOfTurnTeam02

        public void TestThatAllBobsDiesAtEndOfTurnTeam02()
        {
            Character[] tf2Blue = new Character[6];
            for (int i = 0; i < 6; i++)
            {
                tf2Blue[i] = new Character("Bob", null, 10, 10, 10, new Item(), "Warrior");
            }

            Character[] tf2Red = new Character[6];
            for (int i = 0; i < 6; i++)
            {
                tf2Red[i] = new Character("Bob", null, 10, 10, 10, new Item(), "Warrior");
            }
            var target = new GameBoard(null, tf2Blue, tf2Red, null, null);

            for (int i = 0; i < 6; i++)
            {
                Effect effThat = new Effect("health", 1, 100.0, true, target.getSecondTeamCharacters()[i]);
                target.addEffect(effThat);
            }

            target.turn();
            Assert.AreEqual(target.getSecondTeamCharacters()[0].GetDead(), true);
            Assert.AreEqual(target.getSecondTeamCharacters()[1].GetDead(), true);
            Assert.AreEqual(target.getSecondTeamCharacters()[2].GetDead(), true);
            Assert.AreEqual(target.getSecondTeamCharacters()[3].GetDead(), true);
            Assert.AreEqual(target.getSecondTeamCharacters()[4].GetDead(), true);
            Assert.AreEqual(target.getSecondTeamCharacters()[5].GetDead(), true);
        }
开发者ID:heidtbkd,项目名称:heidtbkd---TacCom,代码行数:29,代码来源:GameBoadTest.cs

示例10: TestThatGameBoardChangesToOriginalTurnPerson

 public void TestThatGameBoardChangesToOriginalTurnPerson()
 {
     var target = new GameBoard(null, null, null, null, null);
     target.turn();
     target.turn();
     Assert.True(target.getTurn());
 }
开发者ID:heidtbkd,项目名称:heidtbkd---TacCom,代码行数:7,代码来源:GameBoadTest.cs

示例11: GameBoard_TestShowBoard

        public void GameBoard_TestShowBoard()
        {
            GameBoard gameBoard = new GameBoard();
            StringWriter stringWriter = new StringWriter();
            using (stringWriter)
            {
                Console.SetOut(stringWriter);

                gameBoard.ShowBoard();

                string expectedString =
            @"
            UL  0 1 2 3 4 5 6 7  UR
               _________________
            0 | A   B   C   D   | 0
            1 |                 | 1
            2 |                 | 2
            3 |                 | 3
            4 |                 | 4
            5 |                 | 5
            6 |                 | 6
            7 |       K         | 7
              |_________________|
            DL  0 1 2 3 4 5 6 7  DR

            ";
                Assert.AreEqual(expectedString, stringWriter.ToString());
            }
        }
开发者ID:TeamRadonQPCProject,项目名称:RadonProject,代码行数:29,代码来源:GameBoard.Test.cs

示例12: GameBlockBase

 protected GameBlockBase(GameBoard gameBoard, int indexRow, int indexColumn)
 {
     this.gameBoard = gameBoard;
     this.gameBoard.GameBlocks[indexRow, indexColumn] = this;
     this.indexRow = indexRow;
     this.indexColumn = indexColumn;
 }
开发者ID:ttat,项目名称:puzzlewarrior,代码行数:7,代码来源:GameBlockBase.cs

示例13: GetNextMove_Impl

        protected override IMove GetNextMove_Impl(IGameBoard board)
        {
            m_GameBoard = board as GameBoard;
            InkCollectorStrokeEventHandler handler = new InkCollectorStrokeEventHandler(m_InkPicture_Stroke);
            IMove move = null;

            m_Waiter = new EventWaitHandle(false, EventResetMode.ManualReset);
            m_InkPicture.Stroke += handler;

            try
            {
                while (move == null)
                {
                    m_Waiter.Reset();
                    if (m_Waiter.WaitOne())
                    {
                        move = m_Move;
                    }
                }
            }
            finally
            {
                m_InkPicture.Stroke -= handler;
            }

            return move;
        }
开发者ID:bubbafat,项目名称:Dots-and-Boxes-Game,代码行数:27,代码来源:InkInputPlayer.cs

示例14: IndexToCoords_IsCorrect

 public void IndexToCoords_IsCorrect()
 {
     var board = new GameBoard();
     int x;
     int y;
     board.IndexToCoords(0,out x,out y);
     Assert.AreEqual(0, x);
     Assert.AreEqual(0, y);
     board.IndexToCoords(1,out x,out y);
     Assert.AreEqual(1, x);
     Assert.AreEqual(0, y);
     board.IndexToCoords(2,out x,out y);
     Assert.AreEqual(2, x);
     Assert.AreEqual(0, y);
     board.IndexToCoords(3,out x,out y);
     Assert.AreEqual(0, x);
     Assert.AreEqual(1, y);
     board.IndexToCoords(4,out x,out y);
     Assert.AreEqual(1, x);
     Assert.AreEqual(1, y);
     board.IndexToCoords(5,out x,out y);
     Assert.AreEqual(2, x);
     Assert.AreEqual(1, y);
     board.IndexToCoords(6,out x,out y);
     Assert.AreEqual(0, x);
     Assert.AreEqual(2, y);
     board.IndexToCoords(7,out x,out y);
     Assert.AreEqual(1, x);
     Assert.AreEqual(2, y);
     board.IndexToCoords(8,out x,out y);
     Assert.AreEqual(2, x);
     Assert.AreEqual(2, y);
 }
开发者ID:kellyelton,项目名称:Tic-Tac-Toe,代码行数:33,代码来源:GameBoardTests.cs

示例15: FatBossZombie

        //private LinkedList<BabyZombie> babies;
        public FatBossZombie(int x, int y, int maxX, int minX, int maxY, int minY, Darwin dar, GameBoard gb)
            : base(x, y, maxX, minX, maxY, minY, gb)
        {
            darwin = dar;

            destination.Height = board.getSquareLength() * 3;
            destination.Width = board.getSquareWidth() * 3;

            source = new Rectangle(0, 0, 128, 128);

            setEventLag(10);

            explodeSource = new Rectangle[4];
            explodeSource[0] = new Rectangle(0, 0, 75, 90);
            explodeSource[1] = new Rectangle(0, 0, 75, 90);
            explodeSource[2] = new Rectangle(76, 0, 87, 90);
            explodeSource[3] = new Rectangle(169, 0, 101, 90);

            ran = new Random();
            ran1 = new Random();

            deathExplodeCount = new int[9];
            deathExplodeBool = new bool[9];

            for (int i = 0; i < 9; i++)
            {
                deathExplodeBool[i] = new bool();
                deathExplodeCount[i] = new int();
            }

            reset();
            ZOMBIE_MOVE_RATE = 50;
        }
开发者ID:rizzen93,项目名称:legendofdarwin,代码行数:34,代码来源:FatBossZombie.cs


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