StatusBarManager.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using FSEvent;
  6. public class StatusBarManager : MonoBehaviour {
  7. public Text roundText;
  8. // Use this for initialization
  9. void Start () {
  10. InitEvents();
  11. }
  12. // Update is called once per frame
  13. void Update () {
  14. }
  15. private void OnDestroy() {
  16. RemoveEvents();
  17. }
  18. /*
  19. * 初始化监听
  20. */
  21. private void InitEvents() {
  22. EventListener.Instance.RegisterEvent(EventEnum.EVENT_UPDATE_ROUND_TEXT, UpdateRoundText);
  23. }
  24. /*
  25. * 移除监听
  26. */
  27. private void RemoveEvents() {
  28. EventListener.Instance.RemoveEvent(EventEnum.EVENT_UPDATE_TABLE_INFO);
  29. }
  30. /*
  31. * 更新回合文本
  32. */
  33. private void UpdateRoundText(Dictionary<string, object> info) {
  34. // 从提供的数据中获取要更新的值
  35. if (roundText != null) {
  36. roundText.text = (string)info["remind"];
  37. Invoke("ResetRoundText", 2.0f);
  38. }
  39. }
  40. /*
  41. * 重置提醒
  42. */
  43. private void ResetRoundText() {
  44. roundText.text = "";
  45. }
  46. }