Beispiel #1
0
    IEnumerator DelayedLevelEnd()
    {
        yield return(new WaitForSeconds(1.5f));

        int currentWorld = PlayerPrefs.GetInt("currentWorld");
        int currentLevel = PlayerPrefs.GetInt("currentLevel");

        PlayerPrefs.SetInt("achievedWorld", currentWorld);
        PlayerPrefs.SetInt("achievedLevel", currentLevel);

        PanelPopUp.SetActive(true);

        textCodePlayer.GetComponent <Text>().text   = "";
        textCodeSolution.GetComponent <Text>().text = "";

        Star1Fill.SetActive(false);
        Star2Fill.SetActive(false);
        Star3Fill.SetActive(false);

        float tempPercent = levelController.Current.par / (instructionCount * 1.0f);
        int   numStars;

        if (tempPercent >= 1)
        {
            numStars = 3;
        }
        else if (tempPercent >= .4)
        {
            numStars = 2;
        }
        else
        {
            numStars = 1;
        }

        StartCoroutine(showStars(numStars));

        // Save the numStars to PlayerPrefs
        int[] starsArray = new int[4];

        starsArray = PlayerPrefsX.GetIntArray("NumStars-World-" + currentWorld);
        starsArray[currentLevel] = numStars;
        PlayerPrefsX.SetIntArray("NumStars-World-" + currentWorld, starsArray);

        HeaderPopUp.GetComponent <Text>().text = positiveAffirmations[Random.Range(0, positiveAffirmations.Length)];
        instructionBodyText2.text = "";
    }
Beispiel #2
0
    IEnumerator showStars(int numStars)
    {
        float pause = 0.85f;

        yield return(new WaitForSeconds(pause));


        // get current # of stars earned and show it here
        int totalStars = PlayerPrefs.GetInt("totalStars");

        TotalStars.GetComponent <Text>().text = "" + totalStars;
        float tempGold = 0;
        float starGold = 100;

        switch (numStars)
        {
        case 1:
            Star1Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold * .25f;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");
            break;

        case 2:
            Star1Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold * .25f;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");

            yield return(new WaitForSeconds(pause));

            Star2Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold * .6f;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");
            break;

        case 3:
            Star1Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold * .25f;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");
            yield return(new WaitForSeconds(pause));

            Star2Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold * .6f;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");
            yield return(new WaitForSeconds(pause));

            Star3Fill.SetActive(true);
            Star1Fill.SetActive(true);
            tempGold = float.Parse(TotalGold.GetComponent <Text>().text) + starGold;
            PlayerPrefs.SetInt("totalGold", (int)tempGold);
            TotalGold.GetComponent <Text>().text = tempGold.ToString("N0");
            break;

        default:
            break;
        }

        Text textPlayer = textCodePlayer.GetComponent <Text>();

        StartCoroutine(ShowCode(false, false, allCode, textPlayer));

        yield return(new WaitForSeconds(pause * allCode.Count));

        Text textCode = textCodeSolution.GetComponent <Text>();

        StartCoroutine(ShowCode(false, true, levelController.Current.solutionCode, textCode));
    }