StudioFilingView.cs 9.6 KB

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