/// <summary> /// Does work whenever a new level is generated. /// </summary> private void OnDungeonGenerated() { CurrentLevel++; var text = PlayerUiScript.GetPlayerUiScript().GetLevelTooltip().GetComponent <TMP_Text>(); if (text != null) { text.text = $"Level {CurrentLevel}"; text.gameObject.SetActive(true); } playerScript.GetPlayer().HealPlayerFull(); StartCoroutine(FadeLevelTextInAndOut()); }
/// <summary> /// Uses an alpha effect to fade text (Level 1, 2, 3, etc) in and out. /// </summary> /// <returns></returns> private IEnumerator FadeLevelTextInAndOut() { var text = PlayerUiScript.GetPlayerUiScript().GetLevelTooltip().GetComponent <TMP_Text>(); if (text == null) { yield break; } text.gameObject.SetActive(true); StartCoroutine(TextFade.FadeTextToFullAlpha(3f * Time.timeScale, text)); yield return(new WaitForSeconds(3f * Time.timeScale)); StartCoroutine(TextFade.FadeTextToZeroAlpha(2f * Time.timeScale, text)); yield return(new WaitForSeconds(2f * Time.timeScale)); text.gameObject.SetActive(false); }
/// <summary> /// Uses an alpha effect to fade text (Level 1, 2, 3, etc) in and out. /// </summary> /// <returns></returns> public static IEnumerator FadeTextInAndOut(string text, float fadeInTime = 3f, float fadeOutTime = 2f) { var textObject = PlayerUiScript.GetPlayerUiScript().GetLevelTooltip().GetComponent <TMP_Text>(); if (textObject == null) { yield break; } textObject.text = text; textObject.gameObject.SetActive(true); _instance.StartCoroutine(TextFade.FadeTextToFullAlpha(fadeInTime * Time.timeScale, textObject)); yield return(new WaitForSeconds(fadeInTime * Time.timeScale)); _instance.StartCoroutine(TextFade.FadeTextToZeroAlpha(fadeOutTime * Time.timeScale, textObject)); yield return(new WaitForSeconds(fadeOutTime * Time.timeScale)); textObject.gameObject.SetActive(false); }