StudioFilingView.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 _filingCfg;
  13. private List<StoryLevelCfg> _storyLevelCfgs;
  14. public override void Dispose()
  15. {
  16. if (_valueBarController != null)
  17. {
  18. _valueBarController.Dispose();
  19. _valueBarController = null;
  20. }
  21. if (_ui != null)
  22. {
  23. _ui.Dispose();
  24. _ui = null;
  25. }
  26. base.Dispose();
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. packageName = UI_StudioFilingUI.PACKAGE_NAME;
  32. _ui = UI_StudioFilingUI.Create();
  33. this.viewCom = _ui.target;
  34. isfullScreen = true;
  35. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  36. _ui.m_list.itemRenderer = RenderListItem;
  37. _ui.m_btnBack.onClick.Add(Hide);
  38. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  39. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  40. _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
  41. _ui.m_btnSuit.onClick.Add(OnBtnSuitClick);
  42. }
  43. protected override void AddEventListener()
  44. {
  45. base.AddEventListener();
  46. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  47. EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  48. EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
  49. EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  50. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  51. }
  52. protected override void OnShown()
  53. {
  54. base.OnShown();
  55. _valueBarController.OnShown();
  56. // _valueBarController.Controller(1);
  57. UpdateView();
  58. Timers.inst.AddUpdate(CheckGuide);
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. _valueBarController.OnHide();
  64. Timers.inst.Remove(CheckGuide);
  65. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  66. }
  67. protected override void RemoveEventListener()
  68. {
  69. base.RemoveEventListener();
  70. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  71. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  72. EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
  73. EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  74. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  75. }
  76. private void UpdateView()
  77. {
  78. StudioData studioData = StudioDataManager.Instance.GetStudioDataById(StudioDataManager.Instance.filingChapterId);
  79. _filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  80. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath(_filingCfg.res);
  81. _ui.m_btnChange.title = _filingCfg.name;
  82. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", studioData.TotalPlayTimes - studioData.PlayTimes, _filingCfg.num);
  83. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  84. _ui.m_txtSuitName.text = suitCfg.name;
  85. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_filingCfg.suitId, out int count, out int totalCount);
  86. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  87. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_filingCfg.type, _filingCfg.subType, StudioDataManager.Instance.filingChapterId);
  88. _ui.m_list.numItems = _storyLevelCfgs.Count;
  89. UpdateRedDot();
  90. }
  91. private void RenderListItem(int index, GObject obj)
  92. {
  93. // int _index = _storyLevelCfgs.Count - index - 1;
  94. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  95. item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  96. item.m_txtName.text = _storyLevelCfgs[index].name;
  97. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  98. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  99. item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  100. if (isFight)
  101. {
  102. item.m_loaBg.url = "ui://Studio/cyjd_di_1";
  103. item.m_loaIcon.visible = false;
  104. item.m_loaItem.visible = true;
  105. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  106. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  107. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  108. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  109. if (item.m_loaItem.data == null)
  110. {
  111. item.m_loaItem.onClick.Add(OnLoaItemClick);
  112. }
  113. item.m_loaItem.data = index;
  114. }
  115. else
  116. {
  117. item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  118. item.m_loaItem.visible = false;
  119. item.m_loaIcon.visible = true;
  120. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _filingCfg.res);
  121. }
  122. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  123. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  124. if (item.m_loaBg.data == null)
  125. {
  126. item.m_loaBg.onClick.Add(OnListItemClick);
  127. }
  128. item.m_loaBg.data = index;
  129. UI_ListLevelItem.ProxyEnd();
  130. }
  131. private void OnListItemClick(EventContext context)
  132. {
  133. GObject obj = context.sender as GObject;
  134. int index = (int)obj.data;
  135. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  136. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  137. {
  138. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  139. return;
  140. }
  141. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  142. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  143. }
  144. private void OnLoaItemClick(EventContext context)
  145. {
  146. GObject obj = context.sender as GObject;
  147. int index = (int)obj.data;
  148. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  149. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  150. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  151. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  152. GoodsItemTipsController.ShowItemTips(itemId);
  153. }
  154. private void OnBtnChangeClick()
  155. {
  156. ViewManager.Show<StudioFilingNpcView>();
  157. }
  158. private void OnBtnRewardClick()
  159. {
  160. ViewManager.Show<StudioFilingRewardView>();
  161. }
  162. private void OnBtnAddClick()
  163. {
  164. ViewManager.Show<StudioBuyNumView>(StudioDataManager.Instance.filingChapterId);
  165. }
  166. private void OnBtnSuitClick()
  167. {
  168. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  169. if (!InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  170. {
  171. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  172. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  173. return;
  174. }
  175. ViewManager.Show<ClothingSyntheticView>(new object[] { _filingCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true);
  176. }
  177. private void UpdateRedDot()
  178. {
  179. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  180. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  181. }
  182. private void CheckGuide(object param)
  183. {
  184. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  185. {
  186. UpdateToCheckGuide(null);
  187. }
  188. else
  189. {
  190. Timers.inst.Remove(CheckGuide);
  191. }
  192. }
  193. protected override void UpdateToCheckGuide(object param)
  194. {
  195. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  196. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从尊贵的辟邪开始吧~~", 0);
  197. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  198. }
  199. }
  200. }