diff options
| author | chai <215380520@qq.com> | 2024-05-19 16:46:27 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-19 16:46:27 +0800 |
| commit | 8b1fc7063b387542803c6bc214ccf8acb32870bd (patch) | |
| tree | d310eb99872c8215f1c1f67731ec21f0915cd778 /Thronefall_1_0/GameCode/NightscoreUI.cs | |
| parent | 8e13e7e2874adc8982e16d1d2ed2e28d7480b45f (diff) | |
* rename
Diffstat (limited to 'Thronefall_1_0/GameCode/NightscoreUI.cs')
| -rw-r--r-- | Thronefall_1_0/GameCode/NightscoreUI.cs | 295 |
1 files changed, 0 insertions, 295 deletions
diff --git a/Thronefall_1_0/GameCode/NightscoreUI.cs b/Thronefall_1_0/GameCode/NightscoreUI.cs deleted file mode 100644 index 7150c48..0000000 --- a/Thronefall_1_0/GameCode/NightscoreUI.cs +++ /dev/null @@ -1,295 +0,0 @@ -using System.Collections; -using I2.Loc; -using MPUIKIT; -using TMPro; -using UnityEngine; - -public class NightscoreUI : MonoBehaviour -{ - public GameObject nightScorePanel; - - public TextMeshProUGUI baseScore; - - public TextMeshProUGUI timeBonus; - - public TextMeshProUGUI protectionPercentage; - - public TextMeshProUGUI protectionScore; - - public TextMeshProUGUI overallScore; - - public AudioSource pointSFXSource; - - [Header("ANIMATION")] - public MPImage backgroundImage; - - public RectTransform content; - - public RectTransform nightSurviveText; - - public RectTransform nightSurviveNumber; - - public RectTransform timeText; - - public RectTransform timeNumber; - - public RectTransform protectionText; - - public RectTransform protectionNumber; - - public RectTransform overallScoreBG; - - public RectTransform overallScoreNumber; - - public AnimationCurve popCurve; - - public AnimationCurve expandCurve; - - public AnimationCurve bumpCurve; - - public AnimationCurve simpleQuad; - - public static NightscoreUI instance; - - private float initialWaitTime = 3f; - - private float completeWaitTime = 3f; - - private float buildUpSFXVol = 0.8f; - - private float clock; - - private bool shown; - - private void Awake() - { - instance = this; - } - - private void Start() - { - nightScorePanel.SetActive(value: false); - ScoreManager.Instance.OnNightScoreAdd.AddListener(ShowNightScore); - UIFrameManager.instance.onFrameOpen.AddListener(StopPointFillSoundOnPause); - } - - private void StopPointFillSoundOnPause() - { - pointSFXSource.Stop(); - } - - public void ShowNightScore(int _baseScore, int _timeBonus, float _protectionPercentage, int _protectionBonus) - { - if (EnemySpawner.instance.Wavenumber < EnemySpawner.instance.waves.Count - 1) - { - shown = true; - StopAllCoroutines(); - clock = 0f; - StartCoroutine(PlayPopUpAnimation(_baseScore, _timeBonus, _protectionPercentage, _protectionBonus)); - } - } - - public void HideNightScore() - { - shown = false; - pointSFXSource.Stop(); - StopAllCoroutines(); - StartCoroutine(PlayHideAnimation()); - } - - private IEnumerator PlayPopUpAnimation(int basescore, int timebonus, float protectionpercent, int protectionbonus) - { - nightScorePanel.SetActive(value: true); - Vector2 contentSizeDelta = content.sizeDelta; - int currentScore = ScoreManager.Instance.CurrentScore - basescore - timebonus - protectionbonus; - int nextScore = currentScore; - baseScore.text = "+" + basescore; - timeBonus.text = "+" + timebonus; - protectionPercentage.text = LocalizationManager.GetTranslation("Menu/Realm") + " " + Mathf.RoundToInt(protectionpercent * 100f) + "% " + LocalizationManager.GetTranslation("Menu/Protected"); - protectionScore.text = "+" + protectionbonus; - overallScore.text = currentScore.ToString(); - contentSizeDelta.y = 0f; - content.sizeDelta = contentSizeDelta; - nightSurviveText.localScale = Vector3.zero; - nightSurviveNumber.localScale = Vector3.zero; - timeText.localScale = Vector3.zero; - timeNumber.localScale = Vector3.zero; - protectionText.localScale = Vector3.zero; - protectionNumber.localScale = Vector3.zero; - overallScoreBG.localScale = Vector3.zero; - overallScoreNumber.localScale = Vector3.zero; - yield return new WaitForSeconds(initialWaitTime); - float animTime2 = 0.5f; - float timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - overallScoreBG.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - overallScoreNumber.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - overallScoreBG.localScale = Vector3.one; - overallScoreNumber.localScale = Vector3.one; - yield return new WaitForSeconds(0.25f); - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildB, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - content.sizeDelta = contentSizeDelta + Vector2.up * 55f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - content.sizeDelta = contentSizeDelta + Vector2.up * 55f; - contentSizeDelta = content.sizeDelta; - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildC, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - nightSurviveText.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - nightSurviveNumber.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - nightSurviveText.localScale = Vector3.one; - nightSurviveNumber.localScale = Vector3.one; - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildB, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - content.sizeDelta = contentSizeDelta + Vector2.up * 30f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - content.sizeDelta = contentSizeDelta + Vector2.up * 30f; - contentSizeDelta = content.sizeDelta; - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildC, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - protectionText.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - protectionNumber.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - protectionText.localScale = Vector3.one; - protectionNumber.localScale = Vector3.one; - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildB, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - content.sizeDelta = contentSizeDelta + Vector2.up * 30f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - content.sizeDelta = contentSizeDelta + Vector2.up * 30f; - _ = content.sizeDelta; - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildC, buildUpSFXVol); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - timeText.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - timeNumber.localScale = Vector3.one * popCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - timeText.localScale = Vector3.one; - timeNumber.localScale = Vector3.one; - pointSFXSource.Play(); - animTime2 = 1.5f; - timer2 = 0f; - nextScore += basescore + protectionbonus + timebonus; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - overallScore.text = Mathf.RoundToInt(Mathf.Lerp(currentScore, nextScore, Mathf.InverseLerp(0f, animTime2, timer2))).ToString(); - yield return null; - } - currentScore = nextScore; - overallScore.text = currentScore.ToString(); - pointSFXSource.Stop(); - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointLockInMinor); - animTime2 = 0.5f; - timer2 = 0f; - while (timer2 < animTime2) - { - timer2 += Time.deltaTime; - overallScoreBG.localScale = Vector3.one * bumpCurve.Evaluate(Mathf.InverseLerp(0f, animTime2, timer2)); - yield return null; - } - overallScoreBG.localScale = Vector3.one; - yield return new WaitForSeconds(completeWaitTime); - HideNightScore(); - } - - private IEnumerator PlayHideAnimation() - { - pointSFXSource.PlayOneShot(ThronefallAudioManager.Instance.audioContent.PointScreenBuildB, buildUpSFXVol); - Vector2 contentSizeDelta3 = content.sizeDelta; - nightSurviveText.localScale = Vector3.one; - nightSurviveNumber.localScale = Vector3.one; - timeText.localScale = Vector3.one; - timeNumber.localScale = Vector3.one; - protectionText.localScale = Vector3.one; - protectionNumber.localScale = Vector3.one; - overallScoreBG.localScale = Vector3.one; - overallScoreNumber.localScale = Vector3.one; - timeText.localScale = Vector3.zero; - timeNumber.localScale = Vector3.zero; - float animTime4 = 0.4f; - float timer4 = 0f; - while (timer4 < animTime4) - { - timer4 += Time.deltaTime; - content.sizeDelta = contentSizeDelta3 - Vector2.up * 30f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime4, timer4)); - yield return null; - } - content.sizeDelta = contentSizeDelta3 - Vector2.up * 30f; - contentSizeDelta3 = content.sizeDelta; - protectionText.localScale = Vector3.zero; - protectionNumber.localScale = Vector3.zero; - animTime4 = 0.4f; - timer4 = 0f; - while (timer4 < animTime4) - { - timer4 += Time.deltaTime; - content.sizeDelta = contentSizeDelta3 - Vector2.up * 30f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime4, timer4)); - yield return null; - } - content.sizeDelta = contentSizeDelta3 - Vector2.up * 30f; - contentSizeDelta3 = content.sizeDelta; - nightSurviveText.localScale = Vector3.zero; - nightSurviveNumber.localScale = Vector3.zero; - animTime4 = 0.4f; - timer4 = 0f; - while (timer4 < animTime4) - { - timer4 += Time.deltaTime; - if (Mathf.InverseLerp(0f, animTime4, timer4) > 0.425f) - { - backgroundImage.enabled = false; - } - content.sizeDelta = contentSizeDelta3 - Vector2.up * 55f * expandCurve.Evaluate(Mathf.InverseLerp(0f, animTime4, timer4)); - yield return null; - } - content.sizeDelta = contentSizeDelta3 - Vector2.up * 55f; - backgroundImage.enabled = true; - animTime4 = 0.2f; - timer4 = 0f; - while (timer4 < animTime4) - { - timer4 += Time.deltaTime; - overallScoreNumber.localScale = Vector3.one * simpleQuad.Evaluate(Mathf.InverseLerp(animTime4, 0f, timer4)); - overallScoreBG.localScale = Vector3.one * simpleQuad.Evaluate(Mathf.InverseLerp(animTime4, 0f, timer4)); - yield return null; - } - overallScoreNumber.localScale = Vector3.zero; - overallScoreBG.localScale = Vector2.zero; - nightScorePanel.SetActive(value: false); - } -} |
