ManaInfo.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Text;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. public class ManaInfo : Regist
  7. {
  8. public class InfoText
  9. {
  10. public float Timer;
  11. public Text Text;
  12. }
  13. #region 变量
  14. public static CanvasGroup CanvasGroup
  15. {
  16. get
  17. {
  18. if (CanvasGroup_ == null)
  19. {
  20. CanvasGroup_ = ManaReso.Get<CanvasGroup>("J_Info");
  21. }
  22. return CanvasGroup_;
  23. }
  24. set { CanvasGroup_ = value; }
  25. }
  26. public static CanvasGroup CanvasGroup_;
  27. public static bool Lock;
  28. public static float Timer;
  29. public static List<InfoText> TextList = new List<InfoText>();
  30. #endregion
  31. public void Update()
  32. {
  33. Timer -= Time.deltaTime;
  34. if (Timer <= 0 && Lock)
  35. {
  36. Lock = false;
  37. CanvasGroup.TweenBacCG();
  38. }
  39. for (int i = 0; i < TextList.Count; i++)
  40. {
  41. InfoText infoText = TextList[i];
  42. infoText.Timer -= Time.deltaTime;
  43. if (infoText.Timer < 0)
  44. {
  45. infoText.Text.TweenBacGra();
  46. TextList.RemoveAt(i--);
  47. }
  48. }
  49. }
  50. public static void Show(string str, float time)
  51. {
  52. CanvasGroup.TweenForCG();
  53. if (TextList.Count == 5)
  54. {
  55. ManaReso.Save(TextList[0].Text);
  56. TextList.RemoveAt(0);
  57. }
  58. Text text = ManaReso.GetInfoItem();
  59. InfoText infoText = new InfoText();
  60. text.text = str;
  61. text.SetAlpha(1);
  62. infoText.Timer = 45;
  63. infoText.Text = text;
  64. TextList.Add(infoText);
  65. Lock = true;
  66. Timer = time;
  67. }
  68. }