using UnityEngine;
using TMPro;

public class Timer : MonoBehaviour
{
    public TextMeshProUGUI timerText;
    public float remainingTime;
    public Transform sun;
    public float rotationStep;

    
    // Update is called once per frame
    void Update()
    {
        if (remainingTime > 0)
        {
            remainingTime -= Time.deltaTime;
        }
        else if (remainingTime < 0)
        {
            remainingTime = 0;
        }
        
        int minutes = Mathf.FloorToInt(remainingTime / 60);
        int seconds = Mathf.FloorToInt(remainingTime % 60);
        
        timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
        sun.localRotation = Quaternion.Euler(sun.localRotation.eulerAngles.x+rotationStep*Time.deltaTime, sun.localRotation.eulerAngles.y, sun.localRotation.eulerAngles.z);
    }
}
