Exemple #1
0
 public virtual bool IsTeamMateInPosition(IChessPiece[][] board, Vector2 l, ChessPieceType.Color curColor)
 {
     if (board[(int)l.X][(int)l.Y].Color == curColor)
     {
         return(true);
     }
     return(false);
 }
Exemple #2
0
 public bool IsEnemyInPosition(IChessPiece[][] board, Vector2 l, ChessPieceType.Color teamColor)
 {
     if (board[(int)l.X][(int)l.Y].Color == teamColor || board[(int)l.X][(int)l.Y].Color == ChessPieceType.Color.Blank)
     {
         return(false);
     }
     return(true);
 }
 public void ChangeTurn()
 {
     if (turnColor == ChessPieceType.Color.White)
     {
         turnColor = ChessPieceType.Color.Black;
     }
     else
     {
         turnColor = ChessPieceType.Color.White;
     }
 }
 private void DecideScore(ChessPieceType.Color teamColorTaken, int amount)
 {
     if (teamColorTaken == ChessPieceType.Color.Black)
     {
         whiteScore += amount;
     }
     else
     {
         blackScore += amount;
     }
 }
Exemple #5
0
 public void FlipBoard()
 {
     if (flipColor == ChessPieceType.Color.White)
     {
         flipColor = ChessPieceType.Color.Black;
     }
     else
     {
         flipColor = ChessPieceType.Color.White;
     }
 }
 /**
  * Flips the way the board is displayed
  */
 private void FlipBoard()
 {
     drawManager.FlipBoard();
     if (flipColor == ChessPieceType.Color.White)
     {
         flipColor = ChessPieceType.Color.Black;
     }
     else
     {
         flipColor = ChessPieceType.Color.White;
     }
 }
 public BoardManager()
 {
     drawManager   = new BoardDrawManager();
     boardCreator  = new BoardCreatorManager();
     cursorManager = new CursorManager();
     scoreManager  = new ScoreManager();
     gameStack     = new Stack <IChessPiece[][]>();
     currentBoard  = boardCreator.BuildBoard();
     boardCreator.InitializeBoard(currentBoard);
     commandDict  = new Dictionary <ChessPieceType.Type, ICommand>();
     currentPiece = currentBoard[4][4];
     turnColor    = ChessPieceType.Color.White;
 }
 /**
  * Method that changes the turn for all managers
  */
 private void ChangeTurnColor()
 {
     checkMateManager.ChangeTurn();
     drawManager.ChangeTurn();
     scoreManager.ChangeTurn();
     if (turnColor == ChessPieceType.Color.White)
     {
         turnColor = ChessPieceType.Color.Black;
     }
     else
     {
         turnColor = ChessPieceType.Color.White;
     }
 }
        public Vector2 FindKing(IChessPiece[][] board, ChessPieceType.Color color)
        {
            Vector2 retVal = new Vector2(0);

            for (int y = 0; y < board.Length; y++)
            {
                for (int x = 0; x < board.Length; x++)
                {
                    if (board[x][y].Type == ChessPieceType.Type.King && board[x][y].Color == color)
                    {
                        retVal = new Vector2(x, y);
                        return(retVal);
                    }
                }
            }
            return(retVal);
        }
        public ScoreManager()
        {
            turnColor           = ChessPieceType.Color.White;
            backRoundSprite     = SpriteFactory.Instance.MakeScoreManagerBackRoundSprite();
            turnText            = TextSpriteFactory.Instance.CreateNormalFontTextSpriteSprite();
            turnText.Text       = "White's turn";
            blackScoreText      = TextSpriteFactory.Instance.CreateNormalFontTextSpriteSprite();
            blackScoreText.Text = "Black's Score: 0";
            whiteScoreText      = TextSpriteFactory.Instance.CreateNormalFontTextSpriteSprite();
            whiteScoreText.Text = "Whites's Score: 0";
            boardFlipText       = TextSpriteFactory.Instance.CreateNormalFontTextSpriteSprite();
            boardFlipText.Text  = "Flip Board";
            leftArrow           = new ArrowButton(ChessPieceType.Direction.Left, new Vector2(8 * Utilities.PieceWidth, 4 * Utilities.PieceHeight));
            rightArrow          = new ArrowButton(ChessPieceType.Direction.Right, new Vector2(8 * Utilities.PieceWidth + Utilities.PieceWidth, 4 * Utilities.PieceHeight));
            clickDisabled       = false;

            buttonList = new int[2][];
            for (int i = 0; i < 2; i++)
            {
                buttonList[i] = new int[8];
            }

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (i == 0)
                    {
                        buttonList[i][j] = 2 * j;
                    }
                    else
                    {
                        buttonList[i][j] = 2 * j + 1;
                    }
                }
            }
        }
        public void PieceTaken(ChessPieceType.Color teamColorTaken, ChessPieceType.Type pieceTypeTaken)
        {
            switch (pieceTypeTaken)
            {
            case ChessPieceType.Type.Bishop:
                DecideScore(teamColorTaken, 3);
                break;

            case ChessPieceType.Type.King:
                DecideScore(teamColorTaken, 100);
                break;

            case ChessPieceType.Type.Knight:
                DecideScore(teamColorTaken, 3);
                break;

            case ChessPieceType.Type.Pawn:
                DecideScore(teamColorTaken, 1);
                break;

            case ChessPieceType.Type.Queen:
                DecideScore(teamColorTaken, 9);
                break;

            case ChessPieceType.Type.Rook:
                DecideScore(teamColorTaken, 5);
                break;

            case ChessPieceType.Type.Blank:
                DecideScore(teamColorTaken, 0);
                break;

            default:
                break;
            }
        }
 public CheckMateManager(Dictionary <ChessPieceType.Type, ICommand> dict)
 {
     commandDict = dict;
     turnColor   = ChessPieceType.Color.White;
 }
Exemple #13
0
 public BoardDrawManager()
 {
     turnColor  = ChessPieceType.Color.White;
     highlightX = -1;
     highlightY = -1;
 }