summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/DiscussBehaviour.cs
blob: 9a99207687b752e56afcc2ce0b3d043e6df1651a (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
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;
	}
}