private void OnTriggerExit(Collider collision) { if (collision.gameObject.tag == "Hands" && _BoardManager.PlayerIsWhite == isWhite) { _BoardHighlights.HideHighlights(PossibleMoves()); } }
public Move HandleClick(Point clickPos) { //If there has been no piece selected if (selectedPiece == null) { selectedPiece = internalBoard.GetPiece(clickPos); //If the user hasn't selected anything valid, do nothing if (selectedPiece == null || selectedPiece.Colour != colour) { return(null); } //Getting the list of possible moves possibleMoves = internalBoard.GetPossibleMoves(selectedPiece); //Setting the highlights on the board highlightsManager.HighLightAllowedMoves(possibleMoves); return(null); } else { Move thisMove = null; //If the person has clicked on a place is a valid move if (possibleMoves != null) { //Checking by checking if click falls onto any possible move foreach (var possibleMove in possibleMoves) { Point movePos = possibleMove.position; if (clickPos.X == movePos.X && clickPos.Y == movePos.Y) { //Storing the old position of piece so that it can be stored in the move log Point pieceOldPos = selectedPiece.Position; thisMove = internalBoard.MovePiece(selectedPiece, clickPos); thisMove.PlayerID = playerId; //Checking that the piece isn't being promoted checkPromotion(thisMove); } } } //Clearing all moves selectedPiece = null; possibleMoves = null; highlightsManager.HideHighlights(); return(thisMove); } }
public void ResetSelectedPiece() { int prefabindex = 0; if (!selectedPiece.isWhite) { prefabindex += 6; } prefabindex += TypePrefabIndexMap[selectedPiece.type]; _BoardHighlights.HideHighlights(selectedPiece.PossibleMoves()); activePieces.Remove(selectedPiece.Object); selectedPiece.Object.transform.position = new Vector3(6969, -50, 6969); SpawnPiece(prefabindex, selectedPiece.CurrentX, selectedPiece.CurrentY); // selectedPiece.Object.transform.position = new Vector3(selectedPiece.CurrentX + 0.5f, 2f, selectedPiece.CurrentY + 0.5f); // GetTileCentre(selectedPiece.CurrentX, selectedPiece.CurrentY); Debug.Log("reset selected piece to " + selectedPiece.CurrentX + "," + selectedPiece.CurrentY); selectedPiece = null; }