/// <summary> /// Check if a piece needs to be kinged /// </summary> void CheckForKing() { // Get the end drag locations int x = (int)endDrag.x; int y = (int)endDrag.y; // Check if the selected piece is not kinged if (selectedPiece && !selectedPiece.isKing) { bool whiteNeedsKing = selectedPiece.isWhite && y == 7; bool blackNeedsKing = !selectedPiece.isWhite && y == 0; // If the selected piece is white and reached the end of the board if (whiteNeedsKing || blackNeedsKing) { // The selected piece is kinged! selectedPiece.King(); } } }
private void CheckForKing() { int x = (int)endDrag.x; int y = (int)endDrag.y; /// check if the selected piece needs to be kinged /// if (selectedPiece && !selectedPiece.isKing) { bool whiteNeedsKing = selectedPiece.isWhite && y == 7; bool blackNeedsKing = !selectedPiece.isWhite && y == 0; if (selectedPiece.isWhite && y == 7) { selectedPiece.isKing = true; } else if (!selectedPiece.isWhite && y == 0) { selectedPiece.King(); // run animation(s) } } }