ManaInfo.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #region 变量
  9. public static Text Text
  10. {
  11. get
  12. {
  13. if (Text_ == null)
  14. {
  15. Text_ = ManaReso.Get<Text>("J_Info");
  16. }
  17. return Text_;
  18. }
  19. set { Text_ = value; }
  20. }
  21. public static Text Text_;
  22. public static bool Lock;
  23. public static float Timer;
  24. public static List<string> StrList = new List<string>();
  25. #endregion
  26. public void FixedUpdate()
  27. {
  28. Timer -= Time.fixedDeltaTime;
  29. if (Timer <= 0 && Lock)
  30. {
  31. Lock = false;
  32. Text.TweenBacCG();
  33. }
  34. }
  35. public static void Show(string str, float time)
  36. {
  37. StrList.Insert(0, str);
  38. if (StrList.Count == 1)
  39. {
  40. Text.text = str;
  41. }
  42. else if (StrList.Count == 6)
  43. {
  44. StrList.RemoveAt(5);
  45. StringBuilder sb = new StringBuilder();
  46. for (int i = 0; i < StrList.Count; i++)
  47. {
  48. if (i < 4)
  49. {
  50. sb.Append(StrList[i] + '\n');
  51. }
  52. else
  53. {
  54. sb.Append(StrList[i]);
  55. }
  56. }
  57. Text.text = sb.ToString();
  58. }
  59. else
  60. {
  61. Text.text = str + "\n" + Text.text;
  62. }
  63. Text.TweenForCG();
  64. Lock = true;
  65. Timer = time;
  66. }
  67. }