Example #1
0
    void Update()
    {
        if (_timer > RoundDuration && Input.GetKeyDown(KeyCode.S))
        {
            SceneManager.LoadScene(0);
        }
        else if (Time.timeScale == 0f && Input.GetKeyDown(KeyCode.S))
        {
            Time.timeScale = 1f;
            StartCoroutine(AnimateIntro());
        }

        if (_cm.InMenu())
        {
            return;
        }

        _timer += Time.deltaTime;
        if (_timer > RoundDuration && !_over)
        {
            _over          = true;
            Time.timeScale = 0f;
            _cm.ForceUnselect();
            GameOver.GetChild(2).GetComponent <Text>().text = _cm.Item;
            string s = "You provided " + NPC.NeedCounter + " needs.";
            if (NPC.NeedCounter >= 4)
            {
                s += " That was impressing.";
            }
            s += "\n";
            if (NPC.CrateRob)
            {
                s += "You robbed poor old homeless man :( You monster!\n";
            }
            if (NPC.FoodRob)
            {
                s += "You robbed food cart guy :( That's not cool.";
            }
            GameOver.GetChild(3).GetComponent <Text>().text = s;
            GameOver.gameObject.SetActive(true);
        }

        if (_timer < RoundDuration / 2f)
        {
            _spriteRenderer.color = Color.Lerp(DUSK, MIDD, _timer / (RoundDuration / 2f));
        }
        else
        {
            _spriteRenderer.color = Color.Lerp(MIDD, NIGT, (_timer - RoundDuration / 2f) / (RoundDuration / 2f));
        }

        float ratio = _timer / RoundDuration;

        Sun.position = (1f - ratio) * (1f - ratio) * START + 2f * ratio * (1f - ratio) * _mid + ratio * ratio * FINNN;
    }