Example #1
0
 private void ClearSelectedPiece()
 {
     if (currentSelectedPiece != null)
     {
         currentSelectedPiece.gfx.Deselect();
         currentSelectedPiece = null;
     }
 }
Example #2
0
 private void HandleCurrentPlayerPieceSelection(ManagePiece hitMP)
 {
     if (currentSelectedPiece == null || currentSelectedPiece != hitMP)
     {
         SelectPiece(hitMP);
     }
     else if (currentSelectedPiece == hitMP)
     {
         ClearSelectedPiece();
     }
 }
Example #3
0
    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;
        }
    }
Example #4
0
 private void SelectPiece(ManagePiece mp)
 {
     ClearSelectedPiece();
     currentSelectedPiece = mp;
     currentSelectedPiece.gfx.Select();
 }
Example #5
0
 public void HandleClick(Vector2Int clickPos, ManagePiece targetPiece)
 {
     //move event
     Move(clickPos);
 }