InstanceZonesView.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using ET;
  2. using System.Collections;
  3. using UnityEngine;
  4. using FairyGUI;
  5. using UI.InstanceZones;
  6. using System.Collections.Generic;
  7. namespace GFGGame
  8. {
  9. public class InstanceZonesView : BaseView
  10. {
  11. private UI_InstanceZonesUI _ui;
  12. private ValueBarController _valueBarController;
  13. private EffectUI _effectUI1;
  14. private EffectUI _effectUI2;
  15. private EffectUI _effectUI3;
  16. public override void Dispose()
  17. {
  18. EffectUIPool.Recycle(_effectUI2);
  19. _effectUI2 = null;
  20. EffectUIPool.Recycle(_effectUI3);
  21. _effectUI3 = null;
  22. if (_valueBarController != null)
  23. {
  24. _valueBarController.Dispose();
  25. _valueBarController = null;
  26. }
  27. if (_ui != null)
  28. {
  29. _ui.Dispose();
  30. _ui = null;
  31. }
  32. base.Dispose();
  33. }
  34. protected override void OnInit()
  35. {
  36. base.OnInit();
  37. packageName = UI_InstanceZonesUI.PACKAGE_NAME;
  38. _ui = UI_InstanceZonesUI.Create();
  39. viewCom = _ui.target;
  40. isfullScreen = true;
  41. isReturnView = true;
  42. _valueBarController = new ValueBarController(_ui.m_valueBar);
  43. _ui.m_btnStudio.target.onClick.Add(OnClickBtnStudio);
  44. _ui.m_btnTravel.target.onClick.Add(OnClickBtnTravel);
  45. _ui.m_btnPoem.target.onClick.Add(OnClickBtnPoem);
  46. _ui.m_btnField.target.onClick.Add(OnTimeTracingClick);
  47. _ui.m_btnArena.target.onClick.Add(OnClickBtnArena);
  48. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  49. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hzs_bg");
  50. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_bg_eff, "ui_HaiZhiShi", "Bg_All_Tx");
  51. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_fish_eff, "ui_HaiZhiShi", "Bg_Yu");
  52. PreloadSuitModel();
  53. }
  54. protected override void OnShown()
  55. {
  56. base.OnShown();
  57. _valueBarController.OnShown();
  58. _valueBarController.UpdateList(new List<int>() { ConstItemID.POWER });
  59. CheckFunOpen();
  60. UpdateRedDot();
  61. Timers.inst.AddUpdate(CheckGuide);
  62. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_eff, "ui_HaiZhiShi", "Bg_ZhuanChang_NiuQu");
  63. }
  64. protected override void OnHide()
  65. {
  66. base.OnHide();
  67. EffectUIPool.Recycle(_effectUI1);
  68. _effectUI1 = null;
  69. _valueBarController.OnHide();
  70. Timers.inst.Remove(CheckGuide);
  71. }
  72. protected override void AddEventListener()
  73. {
  74. base.AddEventListener();
  75. }
  76. protected override void RemoveEventListener()
  77. {
  78. base.RemoveEventListener();
  79. }
  80. private void CheckGuide(object param)
  81. {
  82. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_PORCELAIN) <= 0
  83. || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_PROPERTY) <= 0
  84. || GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0
  85. || GuideDataManager.IsGuideFinish(ConstGuideId.POEM) <= 0
  86. || GuideDataManager.IsGuideFinish("ClothingSelectView") <= 0)
  87. //|| GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0)
  88. {
  89. UpdateToCheckGuide(null);
  90. }
  91. else
  92. {
  93. Timers.inst.Remove(CheckGuide);
  94. }
  95. }
  96. private void UpdateRedDot()
  97. {
  98. _valueBarController.UpdateRedPoint();
  99. RedDotController.Instance.SetComRedDot(_ui.m_btnStudio.target, RedDotDataManager.Instance.GetStudioFilingRed(), "", -126, 22);
  100. RedDotController.Instance.SetComRedDot(_ui.m_btnTravel.target, RedDotDataManager.Instance.GetTravelRed(), "", -152, 85);
  101. RedDotController.Instance.SetComRedDot(_ui.m_btnField.target, TimeTracingDataManager.Instance.GetLevelRewardStatus() || TimeTracingDataManager.Instance.GetAllChapterReward(), "", -103, 43);
  102. }
  103. private void CheckFunOpen()
  104. {
  105. _ui.m_btnPoem.m_loaLockIcon.visible = !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(MatchingCompetitionGatheringView).Name, false);
  106. _ui.m_btnStudio.m_loaLockIcon.visible = !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(StudioView).Name, false);
  107. _ui.m_btnTravel.m_loaLockIcon.visible = !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(TravelView).Name, false);
  108. _ui.m_btnField.m_loaLockIcon.visible = !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(TimeTracingShowView).Name, false);
  109. _ui.m_btnArena.m_loaLockIcon.visible = !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ArenaView).Name, false);
  110. }
  111. private void OnClickBtnBack()
  112. {
  113. Hide();
  114. }
  115. private void OnClickBtnStudio()
  116. {
  117. ViewManager.Show<StudioView>();
  118. }
  119. private void OnClickBtnTravel()
  120. {
  121. ViewManager.Show<TravelView>();
  122. }
  123. private async void OnClickBtnPoem()
  124. {
  125. if (MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason > 0)
  126. {
  127. if (MatchingCompetitionDataManager.Instance.MatchingState == 1)
  128. {
  129. ViewManager.Show<MatchingCompetitionGatheringView>();
  130. }
  131. else
  132. {
  133. bool result = await MatchingCompetitionSproxy.ReqGetOnePlayers();
  134. if (result)
  135. {
  136. ViewManager.Show<MatchingCompetitionUpLoadView>();
  137. }
  138. else
  139. {
  140. PromptController.Instance.ShowFloatTextPrompt("暂无玩家数据!");
  141. }
  142. }
  143. }
  144. else
  145. {
  146. PromptController.Instance.ShowFloatTextPrompt("搭配赛未开启!");
  147. }
  148. }
  149. private void OnClickBtnField()
  150. {
  151. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.TIAN_YE_DIAO_CHA, 1);
  152. ViewManager.Show<FieldView>();
  153. }
  154. private void OnTimeTracingClick()
  155. {
  156. ViewManager.Show<TimeTracingShowView>();
  157. }
  158. private async void OnClickBtnArena()
  159. {
  160. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ArenaView).Name))
  161. {
  162. return;
  163. }
  164. if (!ArenaDataManager.Instance.IsSeasonOpen)
  165. {
  166. PromptController.Instance.ShowFloatTextPrompt("赛季未开始");
  167. return;
  168. }
  169. await ArenaSproxy.ReqArenaInfos();
  170. ViewManager.Show<ArenaView>(this.viewData);
  171. ViewManager.Show<ArenaLoadingView>();
  172. }
  173. protected override void UpdateToCheckGuide(object param)
  174. {
  175. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  176. //_ui.m_loaGuidestudio.visible = false;
  177. GuideController.TryGuide(_ui.m_btnStudio.target, ConstGuideId.STUDIO_PORCELAIN, 3, "工作室开门啦,进去看看~");
  178. GuideController.TryGuide(_ui.m_btnStudio.target, ConstGuideId.STUDIO_FILING, 3, "工作室有新的任务啦。");
  179. //GuideController.TryGuide(_ui.m_btnField.target, ConstGuideId.FIELD, 2, "外出进行历史考察,会有意想不到的收获哦。");
  180. GuideController.TryGuide(_ui.m_btnStudio.target, ConstGuideId.STUDIO_PROPERTY, 2, "");
  181. //GuideController.TryGuide(_ui.m_btnPoem.target, ConstGuideId.POEM, 1, "在“拍照”中保存的图片都会保存到这里。");
  182. GuideController.TryGuide(_ui.m_btnArena.target, ConstGuideId.ARENA_OPEN, 3, "在这里可以与其他小伙伴比拼搭配哦~");
  183. GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.ENTER_CHAPTER_5, 1, "", -1, false);
  184. GuideController.TryGuide(_ui.m_btnField.target, "TimeTracingShowView", 3, "合成副本可获得奖励和服装哦~");
  185. if (!ArenaDataManager.Instance.IsSeasonOpen)
  186. {
  187. GuideController.TryCompleteGuide(ConstGuideId.ARENA_OPEN, 3);
  188. }
  189. }
  190. private void PreloadSuitModel()
  191. {
  192. List<int> suitIdList = new List<int>() { 201030, 201010, 202006 };
  193. for (int i = 1; i < suitIdList.Count; i++)
  194. {
  195. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitIdList[i]);
  196. ResType resType = ResType.Sprite;
  197. if (suitCfg.aniRes != "")
  198. resType = ResType.Animation;
  199. PreDownloadManager.Instance.PreDownloadSuitRes(suitIdList[i], resType, new int[] { ConstDressUpItemType.BEI_JING }, false);
  200. }
  201. }
  202. }
  203. }