StudioFilingView.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 StudioCfg _filingCfg;
  12. private List<StoryLevelCfg> _storyLevelCfgs;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_StudioFilingUI.PACKAGE_NAME;
  26. _ui = UI_StudioFilingUI.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. _ui.m_list.itemRenderer = RenderListItem;
  30. _ui.m_list.onClickItem.Add(OnListItemClick);
  31. _ui.m_btnBack.onClick.Add(Hide);
  32. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  33. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  34. _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
  35. _ui.m_btnSuit.onClick.Add(OnBtnSuitClick);
  36. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tc_bjbj");
  37. }
  38. protected override void AddEventListener()
  39. {
  40. base.AddEventListener();
  41. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  42. EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  43. EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
  44. EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  45. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. UpdateView();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  56. }
  57. protected override void RemoveEventListener()
  58. {
  59. base.RemoveEventListener();
  60. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  61. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  62. EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
  63. EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
  64. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  65. }
  66. private void UpdateView()
  67. {
  68. StudioData studioData = StudioDataManager.Instance.GetStudioDataById(StudioDataManager.Instance.filingChapterId);
  69. _filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  70. _ui.m_txtTitle.SetVar("name", _filingCfg.name).FlushVars();
  71. _ui.m_loaNpc.url = ResPathUtil.GetNpcPicFPath(_filingCfg.res);
  72. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", studioData.TotalPlayTimes - studioData.PlayTimes, _filingCfg.num);
  73. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  74. _ui.m_txtSuitName.text = suitCfg.name;
  75. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_filingCfg.suitId, out int count, out int totalCount);
  76. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  77. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_filingCfg.type, _filingCfg.subType, StudioDataManager.Instance.filingChapterId);
  78. _ui.m_list.numItems = _storyLevelCfgs.Count;
  79. UpdateRedDot();
  80. }
  81. private void RenderListItem(int index, GObject obj)
  82. {
  83. int _index = _storyLevelCfgs.Count - index - 1;
  84. UI_ListLevel item = UI_ListLevel.Proxy(obj);
  85. item.m_c1.selectedIndex = _index % 2;
  86. item.m_txtName.text = _storyLevelCfgs[_index].name;
  87. item.m_imgLock.visible = _index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[_index - 1].id);
  88. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[_index].id);
  89. item.target.data = _index;// _storyLevelCfgs[_index];
  90. UI_ListLevel.ProxyEnd();
  91. }
  92. private void OnListItemClick(EventContext context)
  93. {
  94. GObject obj = context.data as GObject;
  95. int index = (int)obj.data;
  96. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  97. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  98. {
  99. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  100. return;
  101. }
  102. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  103. // if (!string.IsNullOrEmpty(storyLevelCfg.storyStartID))
  104. // {
  105. // StoryController.ShowFilingStoryDialog(storyLevelCfg);
  106. // }
  107. // else
  108. // {
  109. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  110. // }
  111. }
  112. private void OnBtnChangeClick()
  113. {
  114. ViewManager.Show<StudioFilingNpcView>();
  115. }
  116. private void OnBtnRewardClick()
  117. {
  118. ViewManager.Show<StudioFilingRewardView>();
  119. }
  120. private void OnBtnAddClick()
  121. {
  122. ViewManager.Show<StudioBuyNumView>(StudioDataManager.Instance.filingChapterId);
  123. }
  124. private void OnBtnSuitClick()
  125. {
  126. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  127. if (!InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  128. {
  129. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  130. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  131. return;
  132. }
  133. ViewManager.Show<ClothingSyntheticView>(new object[] { _filingCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true);
  134. }
  135. private void UpdateRedDot()
  136. {
  137. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  138. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  139. }
  140. }
  141. }