diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/CounterUI.cs |
+ init
Diffstat (limited to 'GameCode/CounterUI.cs')
-rw-r--r-- | GameCode/CounterUI.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/GameCode/CounterUI.cs b/GameCode/CounterUI.cs new file mode 100644 index 0000000..a23dd69 --- /dev/null +++ b/GameCode/CounterUI.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.UI.ProceduralImage; + +public class CounterUI : MonoBehaviour +{ + [Range(0f, 1f)] + public float counter; + + public float timeToFill = 10f; + + public ProceduralImage outerRing; + + public ProceduralImage fill; + + public Transform rotator; + + public Transform still; + + private float remainingDuration; + + private bool isAbyssalForm; + + private bool done; + + public UnityEvent doneEvent; + + private void ResetStuff() + { + counter = 0f; + } + + private void Update() + { + if (!done) + { + outerRing.fillAmount = counter; + fill.fillAmount = counter; + rotator.transform.localEulerAngles = new Vector3(0f, 0f, 0f - Mathf.Lerp(0f, 360f, counter)); + counter += TimeHandler.deltaTime / timeToFill; + counter = Mathf.Clamp(counter, -0.1f / timeToFill, 1f); + if (counter >= 1f) + { + done = true; + doneEvent.Invoke(); + } + if (counter <= 0f) + { + rotator.gameObject.SetActive(value: false); + still.gameObject.SetActive(value: false); + } + else + { + rotator.gameObject.SetActive(value: true); + still.gameObject.SetActive(value: true); + } + } + } +} |