コード例 #1
0
 public void comparePieces()
 {
     if (firtPiece.name.Substring(0, 7) == secondPiece.name.Substring(0, 7))
     {
         firtPiece.completePiece();
         secondPiece.completePiece();
         thumbsUp1.transform.position = new Vector3(firtPiece.transform.position.x - 0.3f, firtPiece.transform.position.y - 0.5f, 0);
         thumbsUp2.transform.position = new Vector3(secondPiece.transform.position.x - 0.3f, secondPiece.transform.position.y - 0.5f, 0);
         thumbsUp1.gameObject.SetActive(true);
         thumbsUp2.gameObject.SetActive(true);
         thumbsUp1.state.SetAnimation(0, "animation", false);
         thumbsUp2.state.SetAnimation(0, "animation", false);
         activePieceScriptList.Remove(firtPiece);
         activePieceScriptList.Remove(secondPiece);
         activePiecesList.Remove(firtPiece.transform);
         activePiecesList.Remove(secondPiece.transform);
         correctPairSound.Play();
         if (activePiecesList.Count == 0)
         {
             isGameOver = true;
             StartCoroutine(finishMenuGetter());
         }
     }
     else
     {
         wrongPairSound.Play();
         StartCoroutine(warningPopUpGetter());
         firtPiece.resetPiece();
         secondPiece.resetPiece();
     }
     firtPiece   = null;
     secondPiece = null;
 }
コード例 #2
0
    void shufflePiece(Transform piece, Renderer pieceRanderer, PairGamePiece pieceScript)
    {
        isOverLap = false;
        piece.gameObject.SetActive(true);
        piece.localPosition = new Vector2(Random.Range(minXPos, maxXPos), Random.Range(minYPos, maxYPos));
        for (int i = 0; i < activePiecesList.Count; i++)
        {
            if (piece.name != activePiecesList[i].name && activePiecesList[i].gameObject.activeSelf)
            {
                if (pieceRanderer.bounds.Intersects(activePiecesRenderersList[i].bounds))
                {
                    isOverLap = true;
                }
            }
        }

        if (isOverLap)
        {
            shufflePiece(piece, pieceRanderer, pieceScript);
        }
        else
        {
            tempDifficulty = RestrictionMap.findDifficulty(piece.position);
            if (tempDifficulty == 0)
            {
                pieceScript.setPieceActive(2);
            }
            else if (tempDifficulty == 1)
            {
                pieceScript.setPieceActive(3);
            }
            else if (tempDifficulty == 2)
            {
                pieceScript.setPieceActive(4);
            }
            else if (tempDifficulty == 3 || tempDifficulty == 4 || tempDifficulty == 5)
            {
                pieceScript.setPieceActive(1);
            }
        }
    }