ActivityMainTipsView.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using FairyGUI;
  2. using UI.ActivityMain;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using cfg.GfgCfg;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class ActivityMainTipsView : BaseWindow
  10. {
  11. private UI_ActivityMainTipsUI _ui;
  12. private List<AdCfg> activitydata;
  13. private List<AdCfg> showActivity = new List<AdCfg>();
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_ActivityMainTipsUI.PACKAGE_NAME;
  27. _ui = UI_ActivityMainTipsUI.Create();
  28. this.viewCom = _ui.target;
  29. isfullScreen = true;
  30. modal = true;
  31. _ui.m_icon.onClick.Add(OnBtnAdJump);
  32. _ui.m_btnChange.onClick.Add(OnClickChange);
  33. _ui.m_backBtn.onClick.Add(OnClickChange);
  34. _ui.m_notTips.onClick.Add(OnClickTips);
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. if (activitydata == null)
  40. {
  41. activitydata = CommonDataManager.Tables.TblAdCfg.DataList;
  42. }
  43. _ui.m_t4.Play();
  44. UpdateInfo();
  45. }
  46. protected async override void OnHide()
  47. {
  48. if (_ui.m_tipImg.visible)
  49. {
  50. ActivityDataManager.Instance.todayActivityTips = 1;
  51. }
  52. else
  53. {
  54. ActivityDataManager.Instance.todayActivityTips = 0;
  55. }
  56. bool result;
  57. result = await ActivitySProxy.ReqActivityTips(NumericType.IsPropYchmActivity,
  58. ActivityDataManager.Instance.todayActivityTips);
  59. base.OnHide();
  60. }
  61. private void UpdateView()
  62. {
  63. long endTime = 0;
  64. if (showActivity.Count > 0 && showActivity[0] != null)
  65. {
  66. if (showActivity[0].ActivityId != 0)
  67. {
  68. ActivityInfo activityInfo =
  69. ActivityGlobalDataManager.Instance.GetActivityInfo(showActivity[0].ActivityId);
  70. endTime = activityInfo.EndTime;
  71. }
  72. else
  73. {
  74. endTime = TimeUtil.DateTimeToTimestamp(showActivity[0].EndTime);
  75. }
  76. }
  77. else
  78. {
  79. this.Hide();
  80. return;
  81. }
  82. long curTime = TimeHelper.ServerNow();
  83. _ui.m_icon.url = ResPathUtil.GetActivityPath(showActivity[0].ActivityNotice, "png");
  84. _ui.m_activityDesc.visible = false;
  85. }
  86. private void UpdateInfo()
  87. {
  88. if (showActivity.Count == 0)
  89. {
  90. for (int i = 0; i < activitydata.Count; i++)
  91. {
  92. AdCfg adCfg = activitydata[i];
  93. if (adCfg.ActivityId > 0)
  94. {
  95. if (ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId) == null) continue;
  96. ActivityInfo activityInfo =
  97. ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId);
  98. if (TimeHelper.ServerNow() < activityInfo.StartTime ||
  99. TimeHelper.ServerNow() > activityInfo.EndTime) continue;
  100. }
  101. if (adCfg.ActivityNotice != null && adCfg.ActivityNotice != "")
  102. {
  103. if (adCfg.ActivityId != 0)
  104. {
  105. ActivityInfo activityInfo =
  106. ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId);
  107. if (TimeHelper.ServerNow() < activityInfo.StartTime ||
  108. TimeHelper.ServerNow() > activityInfo.EndTime)
  109. {
  110. }
  111. else
  112. {
  113. showActivity.Add(adCfg);
  114. continue;
  115. }
  116. }
  117. if (adCfg.StartTime != "" && adCfg.StartTime != null)
  118. {
  119. long startTime = TimeUtil.DateTimeToTimestamp(adCfg.StartTime);
  120. long endTime = TimeUtil.DateTimeToTimestamp(adCfg.EndTime);
  121. if (TimeHelper.ServerNow() < startTime || TimeHelper.ServerNow() > endTime)
  122. {
  123. continue;
  124. }
  125. else
  126. {
  127. showActivity.Add(adCfg);
  128. }
  129. }
  130. }
  131. }
  132. }
  133. UpdateView();
  134. }
  135. private void OnClickChange()
  136. {
  137. _ui.m_t0.Play();
  138. showActivity.RemoveAt(0);
  139. if (showActivity.Count == 0)
  140. {
  141. this.Hide();
  142. return;
  143. }
  144. UpdateView();
  145. _ui.m_t1.Play();
  146. }
  147. private void OnClickTips()
  148. {
  149. if (ActivityDataManager.Instance.todayActivityTips == 0)
  150. {
  151. _ui.m_tipImg.visible = true;
  152. ActivityDataManager.Instance.todayActivityTips = 1;
  153. }
  154. else
  155. {
  156. _ui.m_tipImg.visible = false;
  157. ActivityDataManager.Instance.todayActivityTips = 0;
  158. }
  159. }
  160. private void OnBtnAdJump()
  161. {
  162. AdCfg adCfg = showActivity[0];
  163. object[] param = null;
  164. int jumpIndex = 0;
  165. if (adCfg.JumpId == nameof(LimitChargeView))
  166. {
  167. param = new object[] { adCfg.ActivityId };
  168. }
  169. if (adCfg.JumpId == nameof(NewLimitChargeView))
  170. {
  171. param = new object[] { adCfg.ActivityId };
  172. }
  173. if (adCfg.JumpId == nameof(LuckyBoxView))
  174. {
  175. jumpIndex = adCfg.JumpParam[0];
  176. }
  177. if (adCfg.JumpId == nameof(ClothingSyntheticView))
  178. {
  179. param = new object[] { adCfg.JumpParam[0] };
  180. }
  181. if (jumpIndex != 0)
  182. ViewManager.Show($"GFGGame.{adCfg.JumpId}", jumpIndex);
  183. else
  184. ViewManager.Show($"GFGGame.{adCfg.JumpId}", param);
  185. }
  186. }
  187. }