summaryrefslogtreecommitdiff
path: root/Thronefall_1_0/GameCode/WaveCountPopUp.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:05:01 +0800
committerchai <215380520@qq.com>2024-05-19 16:05:01 +0800
commitc5f145786f4c6d2fe4bea831dfc16e52228920a5 (patch)
treea6ead7ea8266c767d58ed0f816dcd7a1dd75bd65 /Thronefall_1_0/GameCode/WaveCountPopUp.cs
parent48b64e573a1709dc923cb9162b55be0246b3ff63 (diff)
* move
Diffstat (limited to 'Thronefall_1_0/GameCode/WaveCountPopUp.cs')
-rw-r--r--Thronefall_1_0/GameCode/WaveCountPopUp.cs77
1 files changed, 77 insertions, 0 deletions
diff --git a/Thronefall_1_0/GameCode/WaveCountPopUp.cs b/Thronefall_1_0/GameCode/WaveCountPopUp.cs
new file mode 100644
index 0000000..cf4b150
--- /dev/null
+++ b/Thronefall_1_0/GameCode/WaveCountPopUp.cs
@@ -0,0 +1,77 @@
+using System.Collections;
+using TMPro;
+using UnityEngine;
+
+public class WaveCountPopUp : MonoBehaviour, DayNightCycle.IDaytimeSensitive
+{
+ public GameObject popup;
+
+ public AnimationCurve scaleCurve;
+
+ public float animationTime = 0.75f;
+
+ public float initialDelay = 0.5f;
+
+ public float showTime = 3f;
+
+ public TextMeshProUGUI targetText;
+
+ private bool inAnimation;
+
+ private void Start()
+ {
+ popup.SetActive(value: false);
+ DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
+ }
+
+ public void OnDawn_AfterSunrise()
+ {
+ }
+
+ public void OnDawn_BeforeSunrise()
+ {
+ }
+
+ public void OnDusk()
+ {
+ if (!inAnimation)
+ {
+ StartCoroutine(PopUpAnimation());
+ }
+ }
+
+ private IEnumerator PopUpAnimation()
+ {
+ inAnimation = true;
+ popup.SetActive(value: true);
+ popup.transform.localScale = Vector3.zero;
+ float timer2 = 0f;
+ yield return new WaitForSeconds(initialDelay);
+ targetText.text = "<style=Body Numerals>" + (EnemySpawner.instance.Wavenumber + 1) + "</style><style=Body Bold>/</style><style=Body Numerals>" + EnemySpawner.instance.WaveCount;
+ StartCoroutine(PlaySoundDelayed());
+ while (timer2 < animationTime)
+ {
+ timer2 += Time.deltaTime;
+ popup.transform.localScale = Vector3.one * scaleCurve.Evaluate(Mathf.InverseLerp(0f, animationTime, timer2));
+ yield return null;
+ }
+ popup.transform.localScale = Vector3.one;
+ yield return new WaitForSeconds(showTime);
+ timer2 = 0f;
+ while (timer2 < animationTime)
+ {
+ timer2 += Time.deltaTime;
+ popup.transform.localScale = Vector3.one * scaleCurve.Evaluate(Mathf.InverseLerp(animationTime, 0f, timer2));
+ yield return null;
+ }
+ popup.transform.localScale = Vector3.zero;
+ popup.SetActive(value: false);
+ inAnimation = false;
+ }
+
+ private IEnumerator PlaySoundDelayed()
+ {
+ yield return new WaitForSeconds(0.1f);
+ ThronefallAudioManager.Oneshot(ThronefallAudioManager.AudioOneShot.ShowWaveCount);
+ }
+}