Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Shaker.cs
Go to the documentation of this file.
1using DG.Tweening;
2using UnityEngine;
3
4public class Shaker : MonoBehaviour
5{
6 public static void Shake(Transform t, string id, float magnitude)
7 {
8 DOTween.Kill(t);
9 ShakerProfile shakerProfile = ResourceCache.Load<ShakerProfile>("Media/Effect/ScreenEffect/Shaker/" + id);
10 int num = ((Random.Range(0, 2) == 0) ? 1 : (-1));
11 int num2 = ((Random.Range(0, 2) == 0) ? 1 : (-1));
12 _ = t.transform.localPosition;
13 t.transform.localPosition = Vector3.zero;
14 ((shakerProfile.type == ShakerProfile.Type.Shake) ? t.DOShakePosition(shakerProfile.duration, new Vector2((float)num * shakerProfile.power, (float)num2 * shakerProfile.power) * magnitude, shakerProfile.vibrato) : t.DOPunchPosition(new Vector2((float)num * shakerProfile.power, (float)num2 * shakerProfile.power) * magnitude, shakerProfile.duration, shakerProfile.vibrato, shakerProfile.elasticity)).OnComplete(delegate
15 {
16 t.localPosition = Vector3.zero;
17 });
18 }
19
20 public static void Shake(Component t, string id, float magnitude = 1f)
21 {
22 Shake(t.transform, id, magnitude);
23 }
24
25 public static void ShakeCam(string id = "default", float magnitude = 1f)
26 {
27 if ((bool)Camera.main)
28 {
29 Shake(Camera.main.transform.parent, id, magnitude);
30 }
31 }
32}
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
static void Shake(Component t, string id, float magnitude=1f)
Definition: Shaker.cs:20
static void Shake(Transform t, string id, float magnitude)
Definition: Shaker.cs:6