public void Turn(int input) { if ((myState == States.WhiteTurn && ActionMaster.chessBoard[input] < 6) || (myState == States.BlackTurn && (ActionMaster.chessBoard[input] >= 7 || ActionMaster.chessBoard[input] == 0))) { if (myPhase == Phases.ChoosePiece) { chosenPiece = input; if (ActionMaster.chessBoard[chosenPiece] > 0) { myPhase = Phases.ChooseDestination; Debug.Log("Trying to move " + (ui.chessPieces [ActionMaster.chessBoard [chosenPiece] - 1].ToString()) + " from location " + chosenPiece + "."); } else if (ActionMaster.chessBoard[input] == 0) { Debug.Log("You are trying to select an empty field."); } } else if (myPhase == Phases.ChooseDestination) { chosenDestination = input; Debug.Log("To location " + chosenDestination); if (ActionMaster.AvailableMoves(chosenPiece).Contains(chosenDestination)) { MovePiece(chosenPiece, chosenDestination); if (ActionMaster.chessBoard[chosenPiece] == 6 && chosenDestination / 8 == 7) { myPhase = Phases.ChoosePromotion; ui.promotionPanelWhite.SetActive(true); return; } if (ActionMaster.chessBoard[chosenPiece] == 12 && chosenDestination / 8 == 0) { myPhase = Phases.ChoosePromotion; ui.promotionPanelBlack.SetActive(true); return; } // turnsSinceGameStarted++; myPhase = Phases.ChoosePiece; Debug.Log("Move sucessful"); } else { Debug.Log("Move unsucessful"); myPhase = Phases.ChoosePiece; } } else if (myPhase == Phases.ChoosePromotion) { chosenPromotion = input; ActionMaster.chessBoard[chosenDestination] = chosenPromotion; ui.promotionPanelWhite.SetActive(false); ui.promotionPanelBlack.SetActive(false); // turnsSinceGameStarted++; myPhase = Phases.ChoosePiece; Debug.Log("Move sucessful"); } } else if (myState == States.BlackTurn) { if (myPhase == Phases.ChoosePiece) { // TODO } else if (myPhase == Phases.ChooseDestination) { // TODO } } }