From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/FollowerCamera.cs | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Client/Assembly-CSharp/FollowerCamera.cs (limited to 'Client/Assembly-CSharp/FollowerCamera.cs') diff --git a/Client/Assembly-CSharp/FollowerCamera.cs b/Client/Assembly-CSharp/FollowerCamera.cs new file mode 100644 index 0000000..3184542 --- /dev/null +++ b/Client/Assembly-CSharp/FollowerCamera.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections; +using UnityEngine; + +internal class FollowerCamera : MonoBehaviour +{ + public MonoBehaviour Target; + + public Vector2 Offset; + + public bool Locked; + + public float shakeAmount; + + public float shakePeriod = 1f; + + public void FixedUpdate() + { + if (this.Target && !this.Locked) + { + base.transform.position = Vector3.Lerp(base.transform.position, this.Target.transform.position + this.Offset, 5f * Time.deltaTime); + if (this.shakeAmount > 0f) + { + float num = Mathf.PerlinNoise(0.5f, Time.time * this.shakePeriod) * 2f - 1f; + float num2 = Mathf.PerlinNoise(Time.time * this.shakePeriod, 0.5f) * 2f - 1f; + base.transform.Translate(num * this.shakeAmount, num2 * this.shakeAmount, 0f); + } + } + } + + public void ShakeScreen(float duration, float severity) + { + base.StartCoroutine(this.CoShakeScreen(duration, severity)); + } + + private IEnumerator CoShakeScreen(float duration, float severity) + { + WaitForFixedUpdate wait = new WaitForFixedUpdate(); + for (float t = duration; t > 0f; t -= Time.fixedDeltaTime) + { + float d = t / duration; + this.Offset = UnityEngine.Random.insideUnitCircle * d * severity; + yield return wait; + } + this.Offset = Vector2.zero; + yield break; + } + + internal void SetTarget(MonoBehaviour target) + { + this.Target = target; + base.transform.position = this.Target.transform.position + this.Offset; + } +} -- cgit v1.1-26-g67d0