示例#1
0
        public void UpdateAvailableMovesList(Player i_Player)
        {
            eKindOfCell      playersColor = i_Player.DiskColor;
            List <Direction> foundDirection;
            bool             isMoveAvailable;
            PickedCell       foundCell = new PickedCell(0, 0);

            if (i_Player.AvailableMoves.Count != 0)
            {
                i_Player.ClearAvailableMovesList();
            }

            for (int i = 1; i < m_BoardMatrix.GetLength(1) - 1; i++)
            {
                for (int j = 1; j < m_BoardMatrix.GetLength(1) - 1; j++)
                {
                    if (m_BoardMatrix[i, j].CellKind == eKindOfCell.Empty)
                    {
                        // list of neighbours, potential for move
                        foundDirection = findFoeNeighbourDirection(playersColor, i, j);
                        if (foundDirection.Count != 0)
                        {
                            isMoveAvailable = findIfThereIsAMove(foundDirection, i, j, playersColor);
                            if (isMoveAvailable)
                            {
                                foundCell.PickARow    = i;
                                foundCell.PickAColumn = j;
                                i_Player.SetNewAvailableMove(foundCell);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public void UpdateAvailableMovesList(Player i_Player)
        {
            eKindOfCell playersColor = i_Player.DiskColor;
            List<Direction> foundDirection;
            bool isMoveAvailable;
            PickedCell foundCell = new PickedCell(0, 0);

            if (i_Player.AvailableMoves.Count != 0)
            {
                i_Player.ClearAvailableMovesList();
            }

            for (int i = 1; i < m_BoardMatrix.GetLength(1) - 1; i++)
            {
                for (int j = 1; j < m_BoardMatrix.GetLength(1) - 1; j++)
                {
                    if (m_BoardMatrix[i, j].CellKind == eKindOfCell.Empty)
                    {
                        // list of neighbours, potential for move
                        foundDirection = findFoeNeighbourDirection(playersColor, i, j);
                        if (foundDirection.Count != 0)
                        {
                            isMoveAvailable = findIfThereIsAMove(foundDirection, i, j, playersColor);
                            if (isMoveAvailable)
                            {
                                foundCell.PickARow = i;
                                foundCell.PickAColumn = j;
                                i_Player.SetNewAvailableMove(foundCell);
                            }
                        }
                    }
                }
            }
        }