/// <summary> /// Obtiene el texto del tablero /// </summary> public string GetText() { string board = " 0 1 2 3 4 5 6 7" + Environment.NewLine + " A B C D E F G H" + Environment.NewLine; // Obtiene el texto for (int row = 0; row < 8; row++) { // Añade el carácter con la fila board += $"{8 - row} "; for (int column = 0; column < 8; column++) { PieceBaseModel piece = Pieces.GetPiece(new CellModel(row, column)); if (piece == null) { board += "."; } else { switch (piece.Type) { case PieceBaseModel.PieceType.Pawn: board += piece.Color == PieceBaseModel.PieceColor.White ? "P" : "p"; break; case PieceBaseModel.PieceType.Bishop: board += piece.Color == PieceBaseModel.PieceColor.White ? "B" : "b"; break; case PieceBaseModel.PieceType.Knight: board += piece.Color == PieceBaseModel.PieceColor.White ? "N" : "n"; break; case PieceBaseModel.PieceType.Rook: board += piece.Color == PieceBaseModel.PieceColor.White ? "R" : "r"; break; case PieceBaseModel.PieceType.King: board += piece.Color == PieceBaseModel.PieceColor.White ? "K" : "k"; break; case PieceBaseModel.PieceType.Queen: board += piece.Color == PieceBaseModel.PieceColor.White ? "Q" : "q"; break; } } board += " "; } // Añade el número de fila y un salto de línea board += $" {8 - row} {row}" + Environment.NewLine; } // Añade el número de columna board += " A B C D E F G H" + Environment.NewLine + " 0 1 2 3 4 5 6 7"; // Devuelve el texto return(board); }
// Start is called before the first frame update void Start() { movements = Pieces.GetPiece(); for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (movements[0][x, y] == 1) { Block b = Instantiate(blockPref, transform).GetComponent <Block>(); b.transform.localPosition = new Vector2(x, -y); blocks.Add(b); } } } }
/// <summary> /// Comprueba si puede capturar una pieza /// </summary> internal bool CanCapture(PieceBaseModel piece, CellModel cell) { PieceBaseModel target = Pieces.GetPiece(cell); return(target != null && target.Color != piece.Color); }