|
|
- 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 Color Dawn;
- public Color Noon;
-
- float DawnValue;
- float NoonValue;
- float colorDif;
- Image SunImage;
-
- void Start()
- {
- SunImage = Sun.gameObject.GetComponent<Image>();
- SunImage.color = Dawn;
- DawnValue = Dawn.b;
- NoonValue = Noon.b;
- colorDif = Mathf.Abs(NoonValue - DawnValue);
- }
-
- void Update () {
- curTime += 1.0f * Time.deltaTime;
- if (curTime >= MaxTimer)
- {
- //Game Lose code here
- }
-
- Color newColor;
-
- if (curTime > MaxTimer / 2)
- {
- newColor = new Color(SunImage.color.r, SunImage.color.g - colorDif * ((90 / MaxTimer) * Time.deltaTime), SunImage.color.b );
-
- }
- else
- {
- newColor = new Color(SunImage.color.r, SunImage.color.g + colorDif * ((90 / MaxTimer) * Time.deltaTime), SunImage.color.b);
- }
- SunImage.color = newColor;
- Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
-
- }
-
- }
|