예제 #1
0
        private bool MakeNonJump()
        {
            int direction = 1;

            if (_checkerColor == _constants.BlackChecker)
            {
                direction = -1;
            }

            bool moved = false;

            foreach (Point checker in _board.GetAllCheckers(_checkerColor))
            {
                if (moved)
                {
                    break;
                }

                var columnDirections = new[] { 1, -1 };

                for (int columnDirection = 0; columnDirection < columnDirections.Length; columnDirection++)
                {
                    if (moved)
                    {
                        break;
                    }

                    if (_board.IsFreeSpace(checker.X + direction, checker.Y + columnDirections[columnDirection]))
                    {
                        if ((checker.X + direction > -1 && checker.X + direction < _constants.SquaresInBoard) &&
                            (checker.Y + columnDirections[columnDirection] < _constants.SquaresInBoard))
                        {
                            moved = _board.MoveChecker(checker.X, checker.Y, checker.X + direction, checker.Y + columnDirections[columnDirection]);
                        }
                    }
                }
            }
            GameManager.TheGameManager.Draw();
            Thread.Sleep(500);
            return(moved);
        }
예제 #2
0
        private bool SetPlayerMove()
        {
            bool  moveWasMade;
            Point selectedSquare = _board.GetSquare(ParentForm.MouseState.MousePosition);

            if (_board.IsRedChecker(selectedSquare.X, selectedSquare.Y))
            {
                _board.SetCellToSelected(selectedSquare.X, selectedSquare.Y);
            }

            Point selectedChecker = _board.GetSelectedSquare();

            moveWasMade = _board.MoveChecker(selectedChecker.X, selectedChecker.Y, selectedSquare.X, selectedSquare.Y);

            _board.DeSelectAllSelectionsExcept(selectedSquare.X, selectedSquare.Y);
            return(moveWasMade);
        }