diff options
Diffstat (limited to 'Client/Assembly-CSharp/DiscussBehaviour.cs')
-rw-r--r-- | Client/Assembly-CSharp/DiscussBehaviour.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/DiscussBehaviour.cs b/Client/Assembly-CSharp/DiscussBehaviour.cs new file mode 100644 index 0000000..9a99207 --- /dev/null +++ b/Client/Assembly-CSharp/DiscussBehaviour.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections; +using UnityEngine; + +public class DiscussBehaviour : MonoBehaviour +{ + public SpriteRenderer LeftPlayer; + + public SpriteRenderer RightPlayer; + + public SpriteRenderer Text; + + public FloatRange RotateRange = new FloatRange(-5f, 5f); + + public Vector2Range TextTarget; + + public AnimationCurve TextEasing; + + public float Delay = 0.1f; + + public float TextDuration = 0.5f; + + public float HoldDuration = 2f; + + private Vector3 vec; + + public IEnumerator PlayAnimation() + { + this.Text.transform.localPosition = this.TextTarget.min; + yield return this.AnimateText(); + yield return ShhhBehaviour.WaitWithInterrupt(this.HoldDuration); + yield break; + } + + public void Update() + { + this.vec.Set(0f, 0f, this.RotateRange.Lerp(Mathf.PerlinNoise(1f, Time.time * 8f))); + this.LeftPlayer.transform.eulerAngles = this.vec; + this.vec.Set(0f, 0f, this.RotateRange.Lerp(Mathf.PerlinNoise(2f, Time.time * 8f))); + this.RightPlayer.transform.eulerAngles = this.vec; + } + + private IEnumerator AnimateText() + { + for (float t = 0f; t < this.Delay; t += Time.deltaTime) + { + yield return null; + } + Vector3 vec = default(Vector3); + for (float t = 0f; t < this.TextDuration; t += Time.deltaTime) + { + float time = t / this.TextDuration; + this.UpdateText(ref vec, this.TextEasing.Evaluate(time)); + yield return null; + } + this.UpdateText(ref vec, 1f); + yield break; + } + + private void UpdateText(ref Vector3 vec, float p) + { + this.TextTarget.LerpUnclamped(ref vec, p, -7f); + this.Text.transform.localPosition = vec; + } +} |