예제 #1
0
 private void selectPawn(Position position)
 {
     tempPos = position;
     selectedPosition = position;
     selectedPosition.isSelected = true;
     Invalidate();
     Update();
 }
예제 #2
0
 private void setDiferencesXY(Position currPos, out int differenceX, out int differenceY)
 {
     differenceX = tempPos.getX() - currPos.getX();
     differenceY = tempPos.getY() - currPos.getY();
 }
예제 #3
0
 private void movePawn(Position currPos)
 {
     currPos.setPawn(tempPos.getPawn()); // set pawn on position
     deletePawn();
 }
예제 #4
0
        private void movePawnToEmptySpace(Position selectedPosition)
        {
            int distanceX; int distanceY;
            setDiferencesXY(selectedPosition, out distanceX, out distanceY);

            if (isMoveAllowed(selectedPosition, distanceX, distanceY))
            {
                movePawn(selectedPosition);
                nextPlayerTurn();
            }
        }
예제 #5
0
 private bool isMoveAllowed(Position selectedPosition, int distanceX, int distanceY)
 {
     return checkMoveAllowance(selectedPosition, distanceX, distanceY, 1) || (checkMoveAllowance(selectedPosition, distanceX, distanceY, 2) && checkForNearbyPieces(selectedPosition, distanceX, distanceY));
 }
예제 #6
0
 private bool isPositionsEqual(Position pos1, Position pos2)
 {
     if (pos1 != null && pos2 != null)
     {
         if (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY())
             return true;
     }
     return false;
 }
예제 #7
0
        private void drawCell(Graphics g, int marginX, int marginY, int incValue, int a, int y, int x)
        {
            Brush cellColor;
            if (isPositionEven(y, x))
                cellColor = new SolidBrush(Color.White);
            else
                cellColor = new SolidBrush(Color.Black);

            if (validateSelectedPosition(y, x))
                cellColor = new SolidBrush(Color.LightGreen);

            if (isGeneratedStartPawnSet == false)
                positions[x, y] = new Position();

            g.FillRectangle(cellColor, marginX + x * incValue, marginY + y * incValue, a, a);
        }
예제 #8
0
 private void deselectPawn()
 {
     selectedPosition.isSelected = false;
     tempPos = null;
     Invalidate();
     Update();
 }
예제 #9
0
 private bool checkPlayerTurn(Position pos)
 {
     if (!pos.isEmpty && pos.getPawn().getColor().Equals(players[playerNrAllowedToMove].color))
         return true;
     else
     {
         MessageBox.Show("It's "+ (players[playerNrAllowedToMove].color.Name) + " Player move!");
         return false;
     }
 }
예제 #10
0
 private bool checkMoveAllowance(Position selectedPosition, int distanceX, int distanceY, int radius)
 {
     return checkPosition(distanceX, distanceY, radius) && selectedPosition.isEmpty;
 }
예제 #11
0
 private static bool checkForNearbyPieces(Position selectedPosition, int distanceX, int distance)
 {
     return !positions[selectedPosition.getX() + ((distanceX != 0 ? (distanceX > 0 ? distanceX - 1 : distanceX + 1) : 0)),
                             selectedPosition.getY() + ((distance != 0 ? (distance > 0 ? distance - 1 : distance + 1) : 0))].isEmpty;
 }