Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        int updatedSecondsLeft;

        if (daylight.isDay())
        {
            daySecondsLeft    -= Time.deltaTime;
            updatedSecondsLeft = Mathf.RoundToInt(daySecondsLeft);
            UpdateDayText(updatedSecondsLeft.ToString());
            SetDayTheme();
        }
        else
        {
            nightSecondsLeft  -= Time.deltaTime;
            updatedSecondsLeft = Mathf.RoundToInt(nightSecondsLeft);
            UpdateNightText(updatedSecondsLeft.ToString());
            SetNightTheme();
        }

        if (gameRunning && updatedSecondsLeft == 0)
        {
            (daylight.isDay() ? daywin : nightwin).SetActive(true);
            if (spawnedButton != null)
            {
                Destroy(spawnedButton);
            }
            gameRunning = false;
        }

        if (gameRunning && spawnedIndicator == null && spawnedButton == null)
        {
            StartCoroutine(RandomButton());
        }
    }