示例#1
0
 private void QueeningCheck(int x, int y)
 {
     if (board[x, y].CurrentPiece != null && board[x, y].CurrentPiece.GetType().Equals(new Pawn().GetType()))
     {
         if (board[x, y].CurrentPiece.CurrentLocation.Y == 0 || board[x, y].CurrentPiece.CurrentLocation.Y == 7)
         {
             Piece transfer = new Queen();
             transfer.PlayerIndex     = board[x, y].CurrentPiece.PlayerIndex;
             transfer.CurrentLocation = board[x, y].CurrentPiece.CurrentLocation;
             transfer.Position        = board[x, y].CurrentPiece.Position;
             transfer.Color           = board[x, y].CurrentPiece.Color;
             transfer.Initialize(board[x, y].CurrentPiece.Position);
             transfer.LoadGraphicsContent(spriteBatch, content.Load <Texture2D>(@"Content\Whites"));
             transfer.CalculateMoves(this);
             board[x, y].CurrentPiece = transfer;
             if (transfer.PlayerIndex == 1)
             {
                 for (int index = 0; index < 8; index++)
                 {
                     if (player1[index].CurrentLocation.Equals(board[x, y].CurrentPiece.CurrentLocation))
                     {
                         player1[index] = transfer;
                         break;
                     }
                 }
             }
             else
             {
                 for (int index = 0; index < 8; index++)
                 {
                     if (player2[index].CurrentLocation.Equals(board[x, y].CurrentPiece.CurrentLocation))
                     {
                         player2[index] = transfer;
                         break;
                     }
                 }
             }
         }
     }
     CalculateNextTurnMoves();
 }