|
- using System;
- using CIG.Translation;
- using SUISS.Core;
- using SUISS.Scheduling;
- using UnityEngine;
- using UnityEngine.UI;
-
- public class OverlayProgress : MonoBehaviour
- {
- private void Update()
- {
- if (!this._initialized)
- {
- return;
- }
- double gameTime = Timing.Instance.GameTime;
- double num = this._endTime - gameTime;
- if (num < 0.0)
- {
- return;
- }
- double num2 = this._totalDuration - num;
- this._progress.fillAmount = (float)(num2 / this._totalDuration);
- this._timer.LocalizedString = Localization.TimeSpan(TimeSpan.FromSeconds((double)Mathf.RoundToInt((float)num)), false);
- }
-
- public virtual void Initialize(double endTime, double totalDuration)
- {
- this._endTime = endTime;
- this._totalDuration = totalDuration;
- this._initialized = true;
- }
-
- public static OverlayProgress Get(GameObject obj)
- {
- OverlayProgress overlayProgress = obj.GetComponent<OverlayProgress>();
- if (overlayProgress == null)
- {
- overlayProgress = OverlayProgress.Create(obj);
- }
- return overlayProgress;
- }
-
- public static OverlayProgress Create(GameObject go)
- {
- OverlayManager instance = SingletonMonobehaviour<OverlayManager>.Instance;
- return instance.CreateOverlay<OverlayProgress>(go, instance.ProgressPrefab);
- }
-
- [SerializeField]
- private Image _progress;
-
- [SerializeField]
- private LocalizedText _timer;
-
- private double _endTime;
-
- private double _totalDuration;
-
- private bool _initialized;
- }
|