StudioFilingView.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Studio;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class StudioFilingView : BaseWindow
  9. {
  10. private UI_StudioFilingUI _ui;
  11. private ValueBarController _valueBarController;
  12. private StudioCfg _studioCfg;
  13. private List<StoryLevelCfg> _storyLevelCfgs;
  14. private int _viewData = 0;
  15. public override void Dispose()
  16. {
  17. if (_valueBarController != null)
  18. {
  19. _valueBarController.Dispose();
  20. _valueBarController = null;
  21. }
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. _ui = null;
  26. }
  27. base.Dispose();
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. packageName = UI_StudioFilingUI.PACKAGE_NAME;
  33. _ui = UI_StudioFilingUI.Create();
  34. this.viewCom = _ui.target;
  35. isfullScreen = true;
  36. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  37. _ui.m_list.itemRenderer = RenderListItem;
  38. _ui.m_btnBack.onClick.Add(GoBackFrom);
  39. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  40. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  41. _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
  42. _ui.m_btnSuit.onClick.Add(OnBtnSuitClick);
  43. }
  44. protected override void AddEventListener()
  45. {
  46. base.AddEventListener();
  47. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  48. EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  49. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  50. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  51. }
  52. protected override void OnShown()
  53. {
  54. base.OnShown();
  55. _valueBarController.OnShown();
  56. _viewData = this.viewData != null ? (int)this.viewData : 0;
  57. _ui.m_btnChange.visible = _viewData != StudioDataManager.Instance.luckyBoxFilingChapterId;
  58. StudioDataManager.Instance.filingChapterId = _viewData > 0 ? _viewData : StudioDataManager.Instance.npcFilingChapterId;
  59. UpdateView();
  60. Timers.inst.AddUpdate(CheckGuide);
  61. }
  62. protected override void OnHide()
  63. {
  64. base.OnHide();
  65. _valueBarController.OnHide();
  66. Timers.inst.Remove(CheckGuide);
  67. }
  68. protected void GoBackFrom()
  69. {
  70. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  71. }
  72. protected override void RemoveEventListener()
  73. {
  74. base.RemoveEventListener();
  75. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  76. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  77. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  78. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  79. }
  80. private void OnLimitChanged(EventContext context)
  81. {
  82. int limitId = (int)context.data;
  83. if (this._studioCfg.limit != limitId)
  84. {
  85. return;
  86. }
  87. UpdateView();
  88. }
  89. private void UpdateView()
  90. {
  91. _studioCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  92. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit);
  93. var limitCfg = LimitCfgArray.Instance.GetCfg(this._studioCfg.limit);
  94. _ui.m_btnAdd.visible = limitCfg.itemID > 0;
  95. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath(_studioCfg.res);
  96. _ui.m_btnChange.title = _studioCfg.name;
  97. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
  98. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  99. _ui.m_txtSuitName.text = suitCfg.name;
  100. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_studioCfg.suitId, out int count, out int totalCount);
  101. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  102. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png");
  103. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.subType, StudioDataManager.Instance.filingChapterId);
  104. _ui.m_list.numItems = _storyLevelCfgs.Count;
  105. UpdateRedDot();
  106. }
  107. private void RenderListItem(int index, GObject obj)
  108. {
  109. // int _index = _storyLevelCfgs.Count - index - 1;
  110. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  111. item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  112. item.m_txtName.text = _storyLevelCfgs[index].name;
  113. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  114. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  115. item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  116. if (isFight)
  117. {
  118. item.m_loaBg.url = "ui://Studio/cyjd_di_1";
  119. item.m_loaIcon.visible = false;
  120. item.m_loaItem.visible = true;
  121. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  122. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  123. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  124. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  125. if (item.m_loaItem.data == null)
  126. {
  127. item.m_loaItem.onClick.Add(OnLoaItemClick);
  128. }
  129. item.m_loaItem.data = index;
  130. }
  131. else
  132. {
  133. item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  134. item.m_loaItem.visible = false;
  135. item.m_loaIcon.visible = true;
  136. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  137. }
  138. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  139. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  140. if (item.m_loaBg.data == null)
  141. {
  142. item.m_loaBg.onClick.Add(OnListItemClick);
  143. }
  144. item.m_loaBg.data = index;
  145. UI_ListLevelItem.ProxyEnd();
  146. }
  147. private void OnListItemClick(EventContext context)
  148. {
  149. GObject obj = context.sender as GObject;
  150. int index = (int)obj.data;
  151. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  152. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  153. {
  154. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  155. return;
  156. }
  157. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  158. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  159. }
  160. private void OnLoaItemClick(EventContext context)
  161. {
  162. GObject obj = context.sender as GObject;
  163. int index = (int)obj.data;
  164. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  165. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  166. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  167. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  168. GoodsItemTipsController.ShowItemTips(itemId);
  169. }
  170. private void OnBtnChangeClick()
  171. {
  172. ViewManager.Show<StudioFilingNpcView>();
  173. }
  174. private void OnBtnRewardClick()
  175. {
  176. ViewManager.Show<StudioFilingRewardView>();
  177. }
  178. private void OnBtnAddClick()
  179. {
  180. ViewManager.Show<StudioBuyNumView>(_studioCfg.limit);
  181. }
  182. private void OnBtnSuitClick()
  183. {
  184. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  185. if (suitCfg.syntheticStoryLevelId > 0 && !InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  186. {
  187. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  188. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  189. return;
  190. }
  191. if (_viewData == StudioDataManager.Instance.luckyBoxFilingChapterId)
  192. {
  193. int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  194. ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  195. long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
  196. long curTime = TimeHelper.ServerNow();
  197. if (endTime < curTime) return;
  198. ViewManager.Show<LuckyBoxActivityView>(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true);
  199. }
  200. else
  201. {
  202. ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true);
  203. }
  204. }
  205. private void UpdateRedDot()
  206. {
  207. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  208. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  209. }
  210. private void CheckGuide(object param)
  211. {
  212. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  213. {
  214. UpdateToCheckGuide(null);
  215. }
  216. else
  217. {
  218. Timers.inst.Remove(CheckGuide);
  219. }
  220. }
  221. protected override void UpdateToCheckGuide(object param)
  222. {
  223. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  224. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0);
  225. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  226. }
  227. }
  228. }