summaryrefslogtreecommitdiff
path: root/GameCode/MenuEffects.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/MenuEffects.cs
+ init
Diffstat (limited to 'GameCode/MenuEffects.cs')
-rw-r--r--GameCode/MenuEffects.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/GameCode/MenuEffects.cs b/GameCode/MenuEffects.cs
new file mode 100644
index 0000000..5345984
--- /dev/null
+++ b/GameCode/MenuEffects.cs
@@ -0,0 +1,51 @@
+using System.Collections;
+using TMPro;
+using UnityEngine;
+
+public class MenuEffects : MonoBehaviour
+{
+ public static MenuEffects instance;
+
+ public Color nopeColor;
+
+ private void Awake()
+ {
+ instance = this;
+ }
+
+ public void ShakeObject(GameObject objectToShake, Vector3 defaultPos, float amount, float time)
+ {
+ StartCoroutine(DoShakeObject(objectToShake, defaultPos, amount, time));
+ }
+
+ private IEnumerator DoShakeObject(GameObject objectToShake, Vector3 defaultPos, float amount, float time)
+ {
+ float c = 0f;
+ while (c < time)
+ {
+ Vector3 localPosition = defaultPos + Random.onUnitSphere * amount * ((time - c) / time);
+ localPosition.z = defaultPos.z;
+ objectToShake.transform.localPosition = localPosition;
+ c += Time.unscaledDeltaTime;
+ yield return null;
+ }
+ objectToShake.transform.localPosition = defaultPos;
+ }
+
+ public void BlinkInColor(TextMeshProUGUI textToBlink, Color blinkColor, Color defaultColor, float seconds)
+ {
+ StartCoroutine(DoTextColorBlink(textToBlink, blinkColor, defaultColor, seconds));
+ }
+
+ private IEnumerator DoTextColorBlink(TextMeshProUGUI textToBlink, Color blinkColor, Color defaultColor, float seconds)
+ {
+ float c = 0f;
+ while (c < seconds)
+ {
+ textToBlink.color = blinkColor;
+ c += Time.unscaledDeltaTime;
+ yield return null;
+ }
+ textToBlink.color = defaultColor;
+ }
+}