StudioFilingView.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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_list.onClickItem.Add(OnListItemClick);
  38. _ui.m_btnBack.onClick.Add(Hide);
  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_STUDIO_PLAY_TIMES, UpdateView);
  50. EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  51. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  52. }
  53. protected override void OnShown()
  54. {
  55. base.OnShown();
  56. _valueBarController.OnShown();
  57. UpdateView();
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. _valueBarController.OnHide();
  63. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  64. }
  65. protected override void RemoveEventListener()
  66. {
  67. base.RemoveEventListener();
  68. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  69. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  70. EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
  71. EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  72. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  73. }
  74. private void UpdateView()
  75. {
  76. StudioData studioData = StudioDataManager.Instance.GetStudioDataById(StudioDataManager.Instance.filingChapterId);
  77. _filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  78. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath(_filingCfg.res);
  79. _ui.m_btnChange.title = _filingCfg.name;
  80. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", studioData.TotalPlayTimes - studioData.PlayTimes, _filingCfg.num);
  81. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  82. _ui.m_txtSuitName.text = suitCfg.name;
  83. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_filingCfg.suitId, out int count, out int totalCount);
  84. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  85. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_filingCfg.type, _filingCfg.subType, StudioDataManager.Instance.filingChapterId);
  86. _ui.m_list.numItems = _storyLevelCfgs.Count;
  87. UpdateRedDot();
  88. }
  89. private void RenderListItem(int index, GObject obj)
  90. {
  91. // int _index = _storyLevelCfgs.Count - index - 1;
  92. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  93. item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  94. item.m_txtName.text = _storyLevelCfgs[index].name;
  95. string resBg = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID) ? "cyjd_di_1" : "cyjd_di_2";
  96. item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  97. item.m_loaIcon.url = string.Format("ui://Studio/{0}_{1}", _filingCfg.res, index);
  98. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  99. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  100. item.target.data = index;// _storyLevelCfgs[_index];
  101. UI_ListLevelItem.ProxyEnd();
  102. }
  103. private void OnListItemClick(EventContext context)
  104. {
  105. GObject obj = context.data as GObject;
  106. int index = (int)obj.data;
  107. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  108. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  109. {
  110. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  111. return;
  112. }
  113. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  114. // if (!string.IsNullOrEmpty(storyLevelCfg.storyStartID))
  115. // {
  116. // StoryController.ShowFilingStoryDialog(storyLevelCfg);
  117. // }
  118. // else
  119. // {
  120. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  121. // }
  122. }
  123. private void OnBtnChangeClick()
  124. {
  125. ViewManager.Show<StudioFilingNpcView>();
  126. }
  127. private void OnBtnRewardClick()
  128. {
  129. ViewManager.Show<StudioFilingRewardView>();
  130. }
  131. private void OnBtnAddClick()
  132. {
  133. ViewManager.Show<StudioBuyNumView>(StudioDataManager.Instance.filingChapterId);
  134. }
  135. private void OnBtnSuitClick()
  136. {
  137. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  138. if (!InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  139. {
  140. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  141. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  142. return;
  143. }
  144. ViewManager.Show<ClothingSyntheticView>(new object[] { _filingCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true);
  145. }
  146. private void UpdateRedDot()
  147. {
  148. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  149. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  150. }
  151. }
  152. }