StudioFilingView.cs 6.2 KB

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