NoticeDataManager.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using ET;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace GFGGame
  5. {
  6. public class NoticeInfo
  7. {
  8. public int noticeId;
  9. public string title;
  10. public long time;//时间戳,单位秒
  11. public string content = "";
  12. public bool readStatus;//对应的读取状态,true为已读
  13. }
  14. public class NoticeDataManager : SingletonBase<NoticeDataManager>
  15. {
  16. private NoticeInfo _lastNoticeInfo;
  17. public NoticeInfo LastNoticeInfo
  18. {
  19. get
  20. {
  21. return _lastNoticeInfo;
  22. }
  23. set
  24. {
  25. _lastNoticeInfo = value;
  26. }
  27. }
  28. private List<NoticeInfo> _noticeInfos = new List<NoticeInfo>();
  29. public List<NoticeInfo> NoticeInfos
  30. {
  31. get
  32. {
  33. return _noticeInfos;
  34. }
  35. }
  36. private Dictionary<int, NoticeInfo> _noticeInfoDic = new Dictionary<int, NoticeInfo>();
  37. public void UpdateNoticeIdList(NoticeInfo noticeInfo)
  38. {
  39. if (!_noticeInfoDic.ContainsKey(noticeInfo.noticeId))
  40. {
  41. _noticeInfoDic.Add(noticeInfo.noticeId, noticeInfo);
  42. }
  43. else
  44. {
  45. _noticeInfoDic[noticeInfo.noticeId] = noticeInfo;
  46. }
  47. NoticeDicToList();
  48. }
  49. public void UpdateNoticeContent(int noticeId, string content)
  50. {
  51. _noticeInfoDic[noticeId].content = content;
  52. _noticeInfoDic[noticeId].readStatus = true;
  53. NoticeDicToList();
  54. }
  55. public void UpdateSystemNoticeRemove(int noticeId)
  56. {
  57. if (_noticeInfoDic.ContainsKey(noticeId)) _noticeInfoDic.Remove(noticeId);
  58. NoticeDicToList();
  59. }
  60. private void NoticeDicToList()
  61. {
  62. _noticeInfos = _noticeInfoDic.Values.ToList();
  63. _noticeInfos.Sort((NoticeInfo a, NoticeInfo b) =>
  64. {
  65. return b.noticeId.CompareTo(a.noticeId);
  66. });
  67. }
  68. public NoticeInfo GetNoticeInfoById(int noticeId)
  69. {
  70. return _noticeInfoDic[noticeId];
  71. }
  72. public List<AdCfg> UpdateShowActivity()
  73. {
  74. AdCfg[] activitydata = AdCfgArray.Instance.dataArray;
  75. List<AdCfg> showActivity = new List<AdCfg>();
  76. for (int i = 0; i < activitydata.Length; i++)
  77. {
  78. AdCfg adCfg = activitydata[i];
  79. if (adCfg.activityId > 0)
  80. {
  81. if (ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.activityId) == null) continue;
  82. ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.activityId);
  83. if (TimeHelper.ServerNow() < activityInfo.StartTime || TimeHelper.ServerNow() > activityInfo.EndTime) continue;
  84. }
  85. if (adCfg.NoticeTips != null && adCfg.NoticeTips != "")
  86. {
  87. if (adCfg.activityId != 0)
  88. {
  89. ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.activityId);
  90. if (TimeHelper.ServerNow() < activityInfo.StartTime || TimeHelper.ServerNow() > activityInfo.EndTime)
  91. {
  92. }
  93. else
  94. {
  95. showActivity.Add(adCfg);
  96. continue;
  97. }
  98. }
  99. if (adCfg.startTime != "" && adCfg.startTime != null)
  100. {
  101. long startTime = TimeUtil.DateTimeToTimestamp(adCfg.startTime);
  102. long endTime = TimeUtil.DateTimeToTimestamp(adCfg.endTime);
  103. if (TimeHelper.ServerNow() < startTime || TimeHelper.ServerNow() > endTime)
  104. {
  105. continue;
  106. }
  107. else
  108. {
  109. showActivity.Add(adCfg);
  110. }
  111. }
  112. }
  113. }
  114. return showActivity;
  115. }
  116. public bool GetRedDotState(string jumpId, int activityID)
  117. {
  118. switch (jumpId)
  119. {
  120. case "DailySignView":
  121. return RedDotDataManager.Instance.GetActivityDay7Red();
  122. case "LuckyBoxView":
  123. return RedDotDataManager.Instance.GetActLuckyBoxRewardRed(ConstLimitTimeActivityType.ActLimitTsy) || RedDotDataManager.Instance.GetLuckyBoxFreeTimes();
  124. case "NewLimitChargeView":
  125. return RedDotDataManager.Instance.GetLimiteChargeRewardRed(activityID);
  126. case "OpenServerActivityView":
  127. return RedDotDataManager.Instance.GetOpenServerRed();
  128. }
  129. return false;
  130. }
  131. }
  132. }