예제 #1
0
    //check the result of a piece moving from one position to a position with another piece on it
    private void CheckExchangeOfPiecesPosition(PuzzlePiece puzzlePiece, bool oldCorrectValue)
    {
        //piece moved from a correct to an incorrect position
        if (puzzlePiecesList[puzzlePiece.puzzlePiecesIndex].GetPieceType() != rightSolutionList[puzzlePiece.puzzlePiecesIndex] &&
            oldCorrectValue == true)
        {
            puzzlePiece.SetPieceIsInCorrectPosition(false);
            puzzlePiece.ChangeToNormalSprite();
            numberOfCorrectPieces--;
        }

        //piece moved from an incorrect to a correct position
        else if (puzzlePiecesList[puzzlePiece.puzzlePiecesIndex].GetPieceType() == rightSolutionList[puzzlePiece.puzzlePiecesIndex] &&
                 oldCorrectValue == false)
        {
            puzzlePiece.SetPieceIsInCorrectPosition(true);
            puzzlePiece.ChangeToLightSprite();
            numberOfCorrectPieces++;
        }

        CheckLevelCompleted();
    }