StudioFilingView.cs 5.4 KB

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