blob: 95491005e6f5f7526f3ee4086ce683671b5a5002 (
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
60
61
62
63
64
65
66
67
68
69
|
using System.Collections;
using UnityEngine;
public class UnitCommandRadiusAnimation : MonoBehaviour
{
public AnimationCurve animationCurve;
public AnimationCurve hideCurve;
public float animationTime;
public float hideTime = 0.25f;
private bool active;
public bool Active => active;
private void Start()
{
if (!active)
{
base.gameObject.SetActive(value: false);
}
}
public void Activate()
{
active = true;
StopAllCoroutines();
base.gameObject.SetActive(value: true);
StartCoroutine(AnimateShow());
}
public void Deactivate()
{
active = false;
if (base.gameObject.activeSelf)
{
StopAllCoroutines();
StartCoroutine(AnimateHide());
}
}
private IEnumerator AnimateShow()
{
float timer = 0f;
while (timer <= animationTime)
{
timer += Time.deltaTime;
base.transform.localScale = Vector3.one * animationCurve.Evaluate(Mathf.InverseLerp(0f, animationTime, timer));
yield return null;
}
base.transform.localScale = Vector3.one;
}
private IEnumerator AnimateHide()
{
Debug.Log("START ANIMATION");
float timer = 0f;
while (timer <= hideTime)
{
timer += Time.deltaTime;
base.transform.localScale = Vector3.one * hideCurve.Evaluate(Mathf.InverseLerp(0f, hideTime, timer));
yield return null;
}
base.transform.localScale = Vector3.zero;
base.gameObject.SetActive(value: false);
}
}
|