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.

47 lines
1.1 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Timer : MonoBehaviour {
  5. //Time stuff
  6. public float MaxTimer = 120.0f;
  7. float curTime = 0.0f;
  8. public Transform Pivot;
  9. public Transform Sun;
  10. float curRot = 0;
  11. public Color Dawn;
  12. public Color Noon;
  13. void Start()
  14. {
  15. Sun.gameObject.GetComponent<Image>().Color = Dawn;
  16. }
  17. void Update () {
  18. curTime += 1.0f * Time.deltaTime;
  19. if (curTime >= MaxTimer)
  20. {
  21. //Game Lose code here
  22. }
  23. /*
  24. //Move the sun
  25. float reqRot = (curTime / MaxTimer) * 180;
  26. if (reqRot > 180)
  27. {
  28. reqRot = 180;
  29. }
  30. if (reqRot > curRot)
  31. {
  32. float rotDistance = reqRot - curRot;
  33. // Sun.RotateAround(Pivot.transform.position, Sun.transform.forward, rotDistance);
  34. curRot = reqRot;
  35. }
  36. */
  37. Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
  38. }
  39. }