using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Timer : MonoBehaviour { //Time stuff public float MaxTimer = 120.0f; float curTime = 0.0f; public Transform Pivot; public Transform Sun; float curRot = 0; public float Dawn = 125; //FF7D00 125 public float Noon = 248; //FFF800 248 public float sunR; public float sunB; float sunG; float colorDif; public Image SunImage; public GameMode mode; public GameObject lightObj; void Start() { sunG = Dawn; colorDif = Mathf.Abs(Noon - Dawn); } void Update () { curTime += 1.0f * Time.deltaTime; if (curTime >= MaxTimer) { mode.PreGameLose(); } float offset = colorDif * (2 / MaxTimer) * Time.deltaTime; if (curTime > MaxTimer / 2) { sunG -= offset; } else { sunG += offset; } Color32 col = new Color32((byte)sunR, (byte)sunG, (byte)sunB, (byte)255); Debug.Log(col); SunImage.color = col; Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime); lightObj.transform.RotateAround(lightObj.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime); } }