From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/CounterUI.cs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 GameCode/CounterUI.cs (limited to 'GameCode/CounterUI.cs') 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); + } + } + } +} -- cgit v1.1-26-g67d0