Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

62 строки
1.4 KiB

  1. using System;
  2. using CIG.Translation;
  3. using SUISS.Core;
  4. using SUISS.Scheduling;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class OverlayProgress : MonoBehaviour
  8. {
  9. private void Update()
  10. {
  11. if (!this._initialized)
  12. {
  13. return;
  14. }
  15. double gameTime = Timing.Instance.GameTime;
  16. double num = this._endTime - gameTime;
  17. if (num < 0.0)
  18. {
  19. return;
  20. }
  21. double num2 = this._totalDuration - num;
  22. this._progress.fillAmount = (float)(num2 / this._totalDuration);
  23. this._timer.LocalizedString = Localization.TimeSpan(TimeSpan.FromSeconds((double)Mathf.RoundToInt((float)num)), false);
  24. }
  25. public virtual void Initialize(double endTime, double totalDuration)
  26. {
  27. this._endTime = endTime;
  28. this._totalDuration = totalDuration;
  29. this._initialized = true;
  30. }
  31. public static OverlayProgress Get(GameObject obj)
  32. {
  33. OverlayProgress overlayProgress = obj.GetComponent<OverlayProgress>();
  34. if (overlayProgress == null)
  35. {
  36. overlayProgress = OverlayProgress.Create(obj);
  37. }
  38. return overlayProgress;
  39. }
  40. public static OverlayProgress Create(GameObject go)
  41. {
  42. OverlayManager instance = SingletonMonobehaviour<OverlayManager>.Instance;
  43. return instance.CreateOverlay<OverlayProgress>(go, instance.ProgressPrefab);
  44. }
  45. [SerializeField]
  46. private Image _progress;
  47. [SerializeField]
  48. private LocalizedText _timer;
  49. private double _endTime;
  50. private double _totalDuration;
  51. private bool _initialized;
  52. }