summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ShhhBehaviour.cs
blob: 6164c57a24faa3e4ac6b5766f9e6e3552b8fa2f8 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using System.Collections;
using UnityEngine;

public class ShhhBehaviour : MonoBehaviour
{
	public SpriteRenderer Background;

	public SpriteRenderer Body;

	public SpriteRenderer Hand;

	public SpriteRenderer TextImage;

	public float RotateSpeed = 15f;

	public Vector2Range HandTarget;

	public AnimationCurve PositionEasing;

	public FloatRange HandRotate;

	public AnimationCurve RotationEasing;

	public Vector2Range TextTarget;

	public AnimationCurve TextEasing;

	public float Duration = 0.5f;

	public float Delay = 0.1f;

	public float TextDuration = 0.5f;

	public float PulseDuration = 0.1f;

	public float PulseSize = 0.1f;

	public float HoldDuration = 2f;

	public bool Autoplay;

	public void OnEnable()
	{
		if (this.Autoplay)
		{
			Vector3 localScale = default(Vector3);
			this.UpdateHand(ref localScale, 1f);
			this.UpdateText(ref localScale, 1f);
			localScale.Set(1f, 1f, 1f);
			this.Body.transform.localScale = localScale;
			this.TextImage.color = Color.white;
		}
	}

	public IEnumerator PlayAnimation()
	{
		base.StartCoroutine(this.AnimateHand());
		yield return this.AnimateText();
		yield return ShhhBehaviour.WaitWithInterrupt(this.HoldDuration);
		yield break;
	}

	public void Update()
	{
		this.Background.transform.Rotate(0f, 0f, Time.deltaTime * this.RotateSpeed);
	}

	private IEnumerator AnimateText()
	{
		this.TextImage.color = Palette.ClearWhite;
		for (float t = 0f; t < this.Delay; t += Time.deltaTime)
		{
			yield return null;
		}
		Vector3 vec = default(Vector3);
		for (float t = 0f; t < this.PulseDuration; t += Time.deltaTime)
		{
			float num = t / this.PulseDuration;
			float num2 = 1f + Mathf.Sin(3.1415927f * num) * this.PulseSize;
			vec.Set(num2, num2, 1f);
			this.Body.transform.localScale = vec;
			this.TextImage.color = Color.Lerp(Palette.ClearWhite, Palette.White, num * 2f);
			yield return null;
		}
		vec.Set(1f, 1f, 1f);
		this.Body.transform.localScale = vec;
		this.TextImage.color = Color.white;
		yield break;
	}

	private IEnumerator AnimateHand()
	{
		this.Hand.transform.localPosition = this.HandTarget.min;
		Vector3 vec = default(Vector3);
		for (float t = 0f; t < this.Duration; t += Time.deltaTime)
		{
			float p = t / this.Duration;
			this.UpdateHand(ref vec, p);
			yield return null;
		}
		this.UpdateHand(ref vec, 1f);
		yield break;
	}

	private void UpdateHand(ref Vector3 vec, float p)
	{
		this.HandTarget.LerpUnclamped(ref vec, this.PositionEasing.Evaluate(p), -1f);
		this.Hand.transform.localPosition = vec;
		vec.Set(0f, 0f, this.HandRotate.LerpUnclamped(this.RotationEasing.Evaluate(p)));
		this.Hand.transform.eulerAngles = vec;
	}

	private void UpdateText(ref Vector3 vec, float p)
	{
		this.TextTarget.LerpUnclamped(ref vec, p, -2f);
		this.TextImage.transform.localPosition = vec;
	}

	public static IEnumerator WaitWithInterrupt(float duration)
	{
		float timer = 0f;
		while (timer < duration && !ShhhBehaviour.CheckForInterrupt())
		{
			yield return null;
			timer += Time.deltaTime;
		}
		yield break;
	}

	public static bool CheckForInterrupt()
	{
		return Input.anyKeyDown;
	}
}