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.

56 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
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. public float sunR;
  15. public float sunB;
  16. float sunG;
  17. float colorDif;
  18. public Image SunImage;
  19. public GameMode mode;
  20. void Start()
  21. {
  22. sunG = Dawn;
  23. colorDif = Mathf.Abs(Noon - Dawn);
  24. }
  25. void Update () {
  26. curTime += 1.0f * Time.deltaTime;
  27. if (curTime >= MaxTimer)
  28. {
  29. mode.PreGameLose();
  30. }
  31. float offset = colorDif * (2 / MaxTimer) * Time.deltaTime;
  32. if (curTime > MaxTimer / 2)
  33. {
  34. sunG -= offset;
  35. }
  36. else
  37. {
  38. sunG += offset;
  39. }
  40. Color32 col = new Color32((byte)sunR, (byte)sunG, (byte)sunB, (byte)255);
  41. Debug.Log(col);
  42. SunImage.color = col;
  43. Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
  44. }
  45. }