Ejemplo n.º 1
0
        private void addLocationToCell(PossibleMove?i_Cell, ref List <PossibleMove?> i_ListOfPossibleMoves)
        {
            bool         cellFound = false;
            PossibleMove?newMove;

            if (i_Cell != null)
            {
                foreach (PossibleMove?move in i_ListOfPossibleMoves)
                {
                    if (move.Value.isEqualToPoisition(i_Cell.Value.X, i_Cell.Value.Y))
                    {
                        eDirection direction = new eDirection();
                        direction  = i_Cell.Value.Direction;
                        direction |= move.Value.Direction;
                        cellFound  = true;
                        newMove    = new PossibleMove(i_Cell.Value.X, i_Cell.Value.Y, direction);
                        i_ListOfPossibleMoves.Remove(move);
                        i_ListOfPossibleMoves.Add(newMove);
                        break;
                    }
                }

                if (!cellFound)
                {
                    i_ListOfPossibleMoves.Add(i_Cell);
                }
            }
        }
Ejemplo n.º 2
0
        private PossibleMove?getPossibleCellFromDirection(int i_XCoord, int i_YCoord, eDirection i_Direction, Player i_Player)
        {
            int          boardRow = 0, boardCol = 0;
            PossibleMove?possibleMove             = null;
            bool         foundSpaceToPlaceNewMove = false;
            bool         inBoundsOfBoard          = true;

            getDirectionRowAndColumn(ref boardRow, ref boardCol, i_Direction);

            while (!foundSpaceToPlaceNewMove && inBoundsOfBoard)
            {
                i_XCoord += boardRow;
                i_YCoord += boardCol;

                inBoundsOfBoard = m_Board.IsCoordinatesInBounds(i_XCoord, i_YCoord);
                if (!inBoundsOfBoard)
                {
                    break;
                }
                else if (m_Board[i_XCoord, i_YCoord].Color == i_Player.Color)
                {
                    break;
                }
                else if (m_Board[i_XCoord, i_YCoord].Color == Color.Empty || m_Board[i_XCoord, i_YCoord].Color == Color.LimeGreen)
                {
                    foundSpaceToPlaceNewMove = true;
                }
            }

            if (foundSpaceToPlaceNewMove)
            {
                possibleMove = new PossibleMove(i_XCoord, i_YCoord, getOppositeDirection(i_Direction));
            }

            return(possibleMove);
        }