Exemple #1
0
    void UpdateTime()
    {
        if (dayLength > 0)
        {
            float scale = 24 / (dayLength / 60);             //scale real time to game time
            currentTime += Time.deltaTime * scale / 86400;

            float sunAngle = currentTime * 360f;
            transform.localRotation = Quaternion.Euler(new Vector3(sunAngle, 0));

            if (currentTime > 1)
            {
                currentDay++;
                displayDay();
                if (currentDay > yearLength)
                {
                    currentYear++;
                    currentDay = 0;
                    displayDay();
                }
                currentTime = 0;
                climate.incrementDay();
            }
        }
        else
        {
            pause = true;
        }
    }