예제 #1
0
    public void RequestMovement(Piece first, Piece second)
    {
        firstPiece  = first;
        secondPiece = second;

        if (firstPiece == secondPiece)
        {
            throw new System.Exception("COMPARE EQUAL PIECES" + firstPiece + " | " + secondPiece);
        }

        //CHECK TUPPLE
        if (CheckTupple(firstPiece, secondPiece))
        {
            SwapPieces(firstPiece, secondPiece);

            List <Piece> verticalPieces   = CheckVerticalMatches();
            List <Piece> horizontalPieces = CheckHorizontalMatches();

            if (verticalPieces.Count > MatchBehaviour.MINIMUM_MATCH || horizontalPieces.Count > MatchBehaviour.MINIMUM_MATCH)
            {
                List <Piece> totalMatches = new List <Piece>();
                totalMatches.AddRange(horizontalPieces);
                totalMatches.AddRange(verticalPieces);

                DestroyMatches(totalMatches);

                services.NotifyMovement(totalMatches);
            }
            else
            {
                SwapPieces(firstPiece, secondPiece);
            }
        }
    }