StudioFilingView.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 FilingCfg _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. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. UpdateView();
  47. }
  48. protected override void OnHide()
  49. {
  50. base.OnHide();
  51. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  52. }
  53. protected override void RemoveEventListener()
  54. {
  55. base.RemoveEventListener();
  56. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  57. }
  58. private void UpdateView()
  59. {
  60. _filingCfg = FilingCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  61. _ui.m_txtTitle.SetVar("name", _filingCfg.name).FlushVars();
  62. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId);
  63. _ui.m_txtSuitName.text = suitCfg.name;
  64. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_filingCfg.suitId, out int count, out int totalCount);
  65. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  66. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_filingCfg.type, 0, StudioDataManager.Instance.filingChapterId);
  67. _ui.m_list.numItems = _storyLevelCfgs.Count;
  68. }
  69. private void RenderListItem(int index, GObject obj)
  70. {
  71. int _index = _storyLevelCfgs.Count - index - 1;
  72. UI_ListLevel item = UI_ListLevel.Proxy(obj);
  73. item.m_c1.selectedIndex = _index % 2;
  74. item.m_txtName.text = _storyLevelCfgs[_index].name;
  75. item.m_imgLock.visible = _index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[_index - 1].id);
  76. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[_index].id);
  77. item.target.data = _index;// _storyLevelCfgs[_index];
  78. UI_ListLevel.ProxyEnd();
  79. }
  80. private void OnListItemClick(EventContext context)
  81. {
  82. GObject obj = context.data as GObject;
  83. int index = (int)obj.data;
  84. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  85. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  86. {
  87. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  88. return;
  89. }
  90. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  91. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  92. }
  93. private void OnBtnChangeClick()
  94. {
  95. }
  96. private void OnBtnRewardClick()
  97. {
  98. }
  99. private void OnBtnAddClick()
  100. {
  101. }
  102. private void OnBtnSuitClick()
  103. {
  104. }
  105. }
  106. }