-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProjectileHitScale.cs
61 lines (46 loc) · 1.91 KB
/
ProjectileHitScale.cs
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
using System.Collections;
using Landfall.TABS;
using UnityEngine;
using UnityEngine.Events;
namespace HiddenUnits
{
public class ProjectileHitScale : ProjectileHitEffect
{
private void Awake()
{
if (HUMain.InfiniteScalingEnabled) scaleLimit = 9999;
}
public override bool DoEffect(HitData hit)
{
if (!hit.rigidbody || !hit.transform.root.GetComponent<Unit>() || (hit.transform.root.GetComponent<Unit>() && hit.transform.root.GetComponent<Unit>().data.Dead) || (hit.transform.root.GetComponent<Unit>() && hit.transform.root.GetComponent<Unit>().Team == GetComponent<TeamHolder>().team) || hit.transform.GetComponent<Scaling>())
{
return false;
}
StartCoroutine(DoScaling(hit));
return true;
}
private IEnumerator DoScaling(HitData hit)
{
hit.transform.gameObject.AddComponent<Scaling>();
yield return new WaitForSeconds(scaleDelay);
scaleEvent.Invoke();
var t = 0f;
var originalVector = hit.transform.localScale;
while (t < scaleCurve.keys[scaleCurve.keys.Length - 1].time && hit.transform.localScale.magnitude > 0.1f)
{
hit.transform.localScale = originalVector * (scaleCurve.Evaluate(t) * scaleCurveMultiplier);
t += Time.deltaTime;
yield return null;
}
ScaleCount++;
if (ScaleCount >= scaleLimit) Destroy(hit.transform.GetComponent<Scaling>());
}
private int ScaleCount;
public float scaleDelay = 0.5f;
public int scaleLimit = 1;
public AnimationCurve scaleCurve;
public float scaleCurveMultiplier = 1f;
public UnityEvent scaleEvent = new UnityEvent();
public class Scaling : MonoBehaviour { }
}
}