// This method will be used to shuffle the picture cards and place them appropriately into the scene.
    private void ShufflePictures(List <cardBack> inputPictures, List <cardBack> inputLetters)
    {
        Vector3 startPosPictures = originalCard.transform.position;         // position of the first card, all cards will be offset from here
        Vector3 startPosLetters  = originalCard2.transform.position;
        int     n = inputPictures.Count;

        while (n >= 1)
        {
            n--;
            // create random values to shuffle the letters by
            int      k     = Random.Range(0, n + 1);
            int      l     = Random.Range(0, n + 1);
            cardBack temp  = inputLetters[k];
            cardBack temp2 = inputPictures[l];

            inputLetters[k]  = inputLetters[n];
            inputLetters[n]  = temp;
            inputPictures[l] = inputPictures[n];
            inputPictures[n] = temp2;
        }

        for (int i = 0; i < inputPictures.Count; i++)
        {
            float posXX = startPosPictures.x + ((i) % gridCols) * offsetX;
            float posYY = startPosPictures.y + (int)Mathf.Floor((float)(i) / gridCols) * -offsetY;
            // handle the sizing of the letters to fit on screen if there is more than 18
            if (inputPictures.Count >= 18)
            {
                gridCols = 6;
                inputPictures[i].transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
                posXX = startPosPictures.x + ((i) % gridCols) * offsetX / (1.2f);
                posYY = startPosPictures.y + (int)Mathf.Floor((float)(i) / gridCols) * -offsetY / (1.2f);
            }
            if (inputPictures.Count % 5 != 0)
            {
                // work on this, change position of the last few cards if %5 != 0
            }

            inputPictures[i].transform.position = new Vector3(posXX, posYY, startPosPictures.z);             // create a new position based on this offset for the newly instatiated card
        }



        for (int j = 0; j < inputLetters.Count; j++)
        {
            float posX = startPosLetters.x + (j % gridCols) * offsetX;
            float posY = startPosLetters.y + (int)Mathf.Floor((float)(j) / gridCols) * -offsetY;
            // Handle the sizing of the letters to fit on screen if there is more than 18
            if (inputLetters.Count >= 18)
            {
                gridCols = 6;
                inputLetters[j].transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
                posX = startPosLetters.x + (j % gridCols) * offsetX / (1.2f);
                posY = startPosLetters.y + (int)Mathf.Floor((float)(j) / gridCols) * -offsetY / (1.2f);
            }

            inputLetters[j].transform.position = new Vector3(posX, posY, startPosLetters.z);
        }
    }
    // This needs work
    private IEnumerator checkCardType()
    {
        yield return(new WaitForSeconds(.5f));

        firstReveal.Unreveal();

        firstReveal  = null;
        secondReveal = null;
        allow        = true;
    }
Example #3
0
 public void cardChosen(cardBack card)
 {
     if (firstReveal == null) {
         print (PlayerPrefs.GetInt ("letter").ToString ());
         firstReveal = card; // set the first card as the first chosen by user
         Debug.Log ("Id =" + firstReveal.getType ());
         playAudio.PlayOneShot (firstReveal.getClip ()); // play sound once user has decided to choose a card
     } else if (firstReveal.getType () == pictureType) {
         playAudio.Stop (); // stop the audio if a second card is being chosen right away
         secondReveal = card; // if a first card has already been chose, set the secondReveal as the chosen card
         StartCoroutine (checkIDs ()); // begin coroutine of comparing id's between the card
     } else {
         print ("srry you must chose a pic first");
     }
 }
 public void cardChosen(cardBack card)
 {
     if (firstReveal == null)
     {
         print(PlayerPrefs.GetInt("letter").ToString());
         firstReveal = card;                           // set the first card as the first chosen by user
         Debug.Log("Id =" + firstReveal.getType());
         playAudio.PlayOneShot(firstReveal.getClip()); // play sound once user has decided to choose a card
     }
     else if (firstReveal.getType() == pictureType)
     {
         playAudio.Stop();              // stop the audio if a second card is being chosen right away
         secondReveal = card;           // if a first card has already been chose, set the secondReveal as the chosen card
         StartCoroutine(checkIDs());    // begin coroutine of comparing id's between the card
     }
     else
     {
         print("srry you must chose a pic first");
     }
 }
    private IEnumerator checkIDs()
    {
        if (firstReveal.getId() == secondReveal.getId())
        {
            int playThisOne = Random.Range(0, congratulations.Length); // randomize the sounds played each time
            playAudio.PlayOneShot(congratulations[playThisOne]);
            score++;
            Debug.Log("Score: " + score);
            if (score == userChoicePictures.Count)
            {
                Debug.Log("u win"); //
            }
        }
        else
        {
            yield return(new WaitForSeconds(.5f));

            firstReveal.Unreveal();
            secondReveal.Unreveal();
        }
        firstReveal  = null;
        secondReveal = null;
    }
Example #6
0
 private IEnumerator checkIDs()
 {
     if (firstReveal.getId() == secondReveal.getId())
     {
         int playThisOne = Random.Range(0, congratulations.Length); // randomize the sounds played each time
         playAudio.PlayOneShot(congratulations[playThisOne]);
         score++;
         Debug.Log("Score: " + score);
         if (score == userChoicePictures.Count)
         {
             Debug.Log("u win"); //
             //won = true;
             menu.SetActive(true);
         }
     }
     else
     {
         yield return new WaitForSeconds(.5f);
         firstReveal.Unreveal();
         secondReveal.Unreveal();
     }
     firstReveal = null;
     secondReveal = null;
 }
Example #7
0
    // This needs work
    private IEnumerator checkCardType()
    {
        yield return new WaitForSeconds(.5f);
        firstReveal.Unreveal();

        firstReveal = null;
        secondReveal = null;
        allow = true;
    }