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.

48 lines
1.1 KiB

  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 Color Dawn;
  13. public Color Noon;
  14. void Start()
  15. {
  16. Sun.gameObject.GetComponent<Image>().color = Dawn;
  17. }
  18. void Update () {
  19. curTime += 1.0f * Time.deltaTime;
  20. if (curTime >= MaxTimer)
  21. {
  22. //Game Lose code here
  23. }
  24. /*
  25. //Move the sun
  26. float reqRot = (curTime / MaxTimer) * 180;
  27. if (reqRot > 180)
  28. {
  29. reqRot = 180;
  30. }
  31. if (reqRot > curRot)
  32. {
  33. float rotDistance = reqRot - curRot;
  34. // Sun.RotateAround(Pivot.transform.position, Sun.transform.forward, rotDistance);
  35. curRot = reqRot;
  36. }
  37. */
  38. Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
  39. }
  40. }