You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
1.3 KiB

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;
public GameMode mode;
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)
{
mode.PreGameLose();
}
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);
}
}