private void ClearSelectedPiece() { if (currentSelectedPiece != null) { currentSelectedPiece.gfx.Deselect(); currentSelectedPiece = null; } }
private void HandleCurrentPlayerPieceSelection(ManagePiece hitMP) { if (currentSelectedPiece == null || currentSelectedPiece != hitMP) { SelectPiece(hitMP); } else if (currentSelectedPiece == hitMP) { ClearSelectedPiece(); } }
private void HandleClickEvent(Vector3 clickPos) { var hit = Physics2D.Raycast(clickPos, Vector2.zero); ManagePiece hitMP = null; if (hit.collider != null) { hitMP = hit.collider.GetComponent <ManagePiece>(); } //hit a current player piece so we are either selecting or deselecting if (hitMP != null && hitMP.GetPieceColor() == CurrentPlayerTurn) { HandleCurrentPlayerPieceSelection(hitMP); return; } //let the player know they need to sort a piece move if (currentSelectedPiece) { currentSelectedPiece.HandleClick(GameUtils.Vector3ToVector2Int(clickPos), hitMP); currentSelectedPiece = null; } }
private void SelectPiece(ManagePiece mp) { ClearSelectedPiece(); currentSelectedPiece = mp; currentSelectedPiece.gfx.Select(); }
public void HandleClick(Vector2Int clickPos, ManagePiece targetPiece) { //move event Move(clickPos); }