blob: a23dd6953bc518c0ade2100513d183fb2a187400 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
}
}
}
}
|