Beispiel #1
0
    public void SwapWithNeighbor(int dx, int dy)
    {
        int neighborX = BoardPiece.X + dx;
        int neighborY = BoardPiece.Y + dy;

        if (_board.IsOutOfBounds(neighborX, neighborY))
        {
            BoardPiece.EnterReadyForMatchState();
            return;
        }

        var neighbor = _board.GetPieceAt(neighborX, neighborY);

        if (neighbor == null || neighbor.CurrentState != BoardPiece.EState.ReadyForMatch)
        {
            BoardPiece.EnterReadyForMatchState();
            return;
        }

        _board.SelectPiece(neighbor);
        if (_board.IsReadyToSwap())
        {
            _board.SwapCandidates();
        }
    }
Beispiel #2
0
    public void OnPointerClick(PointerEventData eventData)
    {
        BoardPiece.EnterReadyForMatchState();
        if (_board.IsReadyToSwap())
        {
            _board.SwapCandidates();
        }

        _isBeingDragged = false;
    }
Beispiel #3
0
    private void OnFellCompleted()
    {
        BoardPiece.EnterReadyForMatchState();
        if (FellCompleted != null)
        {
            FellCompleted(this, EventArgs.Empty);
        }

        TryToMatch();
    }
Beispiel #4
0
 private void OnSwapCompleted()
 {
     BoardPiece.EnterReadyForMatchState();
     if (_board.IsReadyToSwap())
     {
         if (!TryToMatchSwap())
         {
             _board.SwapCandidates();
         }
         _board.ConfirmSwappedPieces();
     }
 }