示例#1
0
    void Update()
    {
        levelTimer  -= Time.deltaTime;
        guiText.text = (levelTimer.ToString("f0"));
        if ((int)levelTimer == 10)
        {
            audio.Play();
        }

        if (levelTimer <= 1 || (!highlightZebMeercat01 && !highlightZebMeercat02 && !highlightZebMeercat03 && !highlightZebTeller01 && !highlightZebTeller03 && timerObjectZebra.renderer.enabled == false))
        {
            PlayerPrefs.SetInt("Player Score", score.totalScore);
            // calculation for stars. total money divid  by 10 then first star 5/10, second 7/10, third bigger than 8/10
            int perMoneyShare   = (score.totalLevelMoney) / 10;
            int firstStarRange  = 5 * perMoneyShare;
            int secondStarRange = 7 * perMoneyShare;
            int thirdStarRange  = 8 * perMoneyShare;

            if ((score.totalScore - score.lastLevelScore) >= firstStarRange)
            {
                if ((score.totalScore - score.lastLevelScore) >= firstStarRange && (score.totalScore - score.lastLevelScore) < secondStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank02", 1);
                    starsCount = 1;
                }
                if ((score.totalScore - score.lastLevelScore) >= secondStarRange && (score.totalScore - score.lastLevelScore) < thirdStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank02", 2);
                    starsCount = 2;
                }
                if ((score.totalScore - score.lastLevelScore) > thirdStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank02", 3);
                    starsCount = 3;
                }

                PlayerPrefs.SetString("bankReg01_Bank03", "unlocked");

                Destroy(moneyTextMeercat01);
                Destroy(moneyTextMeercat02);
                Destroy(moneyTextMeercat03);
                Destroy(moneyTextTeller01);
                Destroy(moneyTextTeller03);
                Destroy(timerGUIText);

                endResultScript.showResult(starsCount);
            }

            else
            {
                audio.Stop();
                guiText.enabled = false;
                pigEvilScript.pigLaughing();
            }
        }
    }
    void Update()
    {
        levelTimer  -= Time.deltaTime;
        guiText.text = (levelTimer.ToString("f0"));

        if ((int)levelTimer == 10)
        {
            audio.Play();
        }

        if (levelTimer <= 1 || !zebra || (!highlightZebMeercat01 && !highlightZebMeercat02 && !highlightZebMeercat03 && !highlightZebMeercat04 &&
                                          !highlightZebMeercat05 && !highlightZebMeercat06 &&
                                          !highlightZebTeller01 && !highlightZebTeller02 && !highlightZebTeller03 && !highlightZebTeller04 &&
                                          !highlightZebTeller05 && !highlightZebTeller06 && !highlightZebTeller07 && !highlightZebTeller08 &&
                                          !highlightZebTeller09 && !highlightZebTeller10 &&
                                          !highlightZebRabbit01 && !highlightZebRabbit02 && !highlightZebRabbit03 && !highlightZebRabbit04 && !highlightZebRabbit05 &&
                                          !highlightZebSafebox && !highlightZebSafebox02 && !highlightZebSafebox03 &&
                                          timerObjectZebra.renderer.enabled == false))
        {
            PlayerPrefs.SetInt("Player Score", score.totalScore);
            if (dog)
            {
                Destroy(dog);
            }
            // calculation for stars. total money divid  by 10 then first star 5/10, second 7/10, third bigger than 8/10
            int perMoneyShare   = (score.totalLevelMoney) / 10;
            int firstStarRange  = 5 * perMoneyShare;
            int secondStarRange = 7 * perMoneyShare;
            int thirdStarRange  = 8 * perMoneyShare;

            if ((score.totalScore - score.lastLevelScore) >= firstStarRange)
            {
                if ((score.totalScore - score.lastLevelScore) >= firstStarRange && (score.totalScore - score.lastLevelScore) < secondStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank10", 1);
                    starsCount = 1;
                }
                if ((score.totalScore - score.lastLevelScore) >= secondStarRange && (score.totalScore - score.lastLevelScore) < thirdStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank10", 2);
                    starsCount = 2;
                }
                if ((score.totalScore - score.lastLevelScore) > thirdStarRange)
                {
                    PlayerPrefs.SetInt("starsReg01_Bank10", 3);
                    starsCount = 3;
                }

                PlayerPrefs.SetString("bankReg01_Bank10", "unlocked");

                Destroy(timerGUIText);

                if (monkey)
                {
                    monkey.renderer.enabled = false;
                }
                if (zebra)
                {
                    zebra.renderer.enabled = false;
                }
                if (rhino)
                {
                    rhino.renderer.enabled = false;
                }
                endResultScript.showResult(starsCount);
            }
            else
            {
                if (monkey)
                {
                    monkey.renderer.enabled = false;
                }
                if (zebra)
                {
                    zebra.renderer.enabled = false;
                }
                if (rhino)
                {
                    rhino.renderer.enabled = false;
                }

                score.levelFailMoneyBack();
                audio.Stop();
                guiText.enabled = false;
                pigEvilScript.pigLaughing();
            }
        }
    }