BonusTextAnim.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class BonusTextAnim : MonoBehaviour
  5. {
  6. private void Start()
  7. {
  8. this.label = base.GetComponent<UILabel>();
  9. base.StartCoroutine(this.AnimCoroutine());
  10. }
  11. private void Update()
  12. {
  13. }
  14. private IEnumerator AnimCoroutine()
  15. {
  16. base.GetComponent<AudioSource>().Play();
  17. this.label.text = string.Empty;
  18. while (!string.IsNullOrEmpty(this.Text))
  19. {
  20. for (int i = 0; i < 3; i++)
  21. {
  22. char randomChar = "abcdefghijklmnopqrstuvwxyz"[UnityEngine.Random.Range(0, "abcdefghijklmnopqrstuvwxyz".Length)];
  23. randomChar = ((!char.IsLower(this.Text[0])) ? char.ToUpper(randomChar) : randomChar);
  24. UILabel uilabel = this.label;
  25. uilabel.text += randomChar;
  26. yield return new WaitForSeconds(0.02f);
  27. this.label.text = this.label.text.Remove(this.label.text.Length - 1);
  28. }
  29. UILabel uilabel2 = this.label;
  30. uilabel2.text += this.Text[0];
  31. this.Text = this.Text.Remove(0, 1);
  32. yield return new WaitForSeconds(0.02f);
  33. }
  34. base.GetComponent<AudioSource>().Play();
  35. yield return new WaitForSeconds(2f);
  36. UnityEngine.Object.Destroy(base.gameObject);
  37. yield break;
  38. }
  39. public string Text;
  40. private UILabel label;
  41. private const string Alphabat = "abcdefghijklmnopqrstuvwxyz";
  42. }