AnnouncementController.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. /// <summary>
  7. /// 控制公告消息
  8. /// </summary>
  9. public static class AnnouncementController
  10. {
  11. public static CallBack<AnnouncementContent2Client> OnAnnouncementMessage;
  12. private static List<AnnouncementContent2Client> messageCache = new List<AnnouncementContent2Client>();
  13. [RuntimeInitializeOnLoadMethod]
  14. public static void Init()
  15. {
  16. GlobalEvent.AddTypeEvent<AnnouncementContent2Client>(OnAnnouncement);
  17. }
  18. private static void OnAnnouncement(AnnouncementContent2Client e, object[] args)
  19. {
  20. if (OnAnnouncementMessage != null)
  21. OnAnnouncementMessage(e);
  22. }
  23. /// <summary>
  24. /// 获得公告信息缓存
  25. /// </summary>
  26. /// <returns></returns>
  27. public static List<AnnouncementContent2Client> GetMessageCache()
  28. {
  29. return messageCache;
  30. }
  31. public static void AddCache(AnnouncementContent2Client e)
  32. {
  33. messageCache.Add(e);
  34. }
  35. /// <summary>
  36. /// 清除缓存
  37. /// </summary>
  38. public static void ClearCache()
  39. {
  40. messageCache.Clear();
  41. }
  42. /// <summary>
  43. /// 确认已阅读公告信息
  44. /// </summary>
  45. /// <param name="id"></param>
  46. /// <param name="useTag"></param>
  47. public static void ConfirmMessage(string id, string useTag)
  48. {
  49. AnnouncementConfirm2Server msg = new AnnouncementConfirm2Server();
  50. msg.id = id;
  51. msg.useTag = useTag;
  52. JsonMessageProcessingController.SendMessage(msg);
  53. }
  54. }