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.

51 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class Timer : MonoBehaviour {
  6. //Time stuff
  7. public float MaxTimer = 120.0f;
  8. float curTime = 0.0f;
  9. public Transform Pivot;
  10. public Transform Sun;
  11. float curRot = 0;
  12. public float Dawn = 125; //FF7D00 125
  13. public float Noon = 248; //FFF800 248
  14. float colorDif;
  15. Image SunImage;
  16. public GameMode mode;
  17. void Start()
  18. {
  19. SunImage = Sun.gameObject.GetComponent<Image>();
  20. colorDif = Mathf.Abs(Noon - Dawn);
  21. }
  22. void Update () {
  23. curTime += 1.0f * Time.deltaTime;
  24. if (curTime >= MaxTimer)
  25. {
  26. mode.PreGameLose();
  27. }
  28. // Color newColor;
  29. if (curTime > MaxTimer / 2)
  30. {
  31. // newColor = new Color(SunImage.color.r, SunImage.color.g - (colorDif / (1/(0.5 * MaxTimer))), SunImage.color.b);
  32. }
  33. else
  34. {
  35. // newColor = new Color(SunImage.color.r, SunImage.color.g + (colorDif / (1/(0.5 * MaxTimer))), SunImage.color.b);
  36. }
  37. // SunImage.color = newColor;
  38. Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
  39. }
  40. }