StudioActivityView.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 StudioActivityView : BaseWindow
  9. {
  10. private UI_StudioActivityUI _ui;
  11. private ValueBarController _valueBarController;
  12. private StudioCfg _studioCfg;
  13. private List<StoryLevelCfg> _storyLevelCfgs;
  14. private int _itemIndex = 0;
  15. public override void Dispose()
  16. {
  17. if (_valueBarController != null)
  18. {
  19. _valueBarController.Dispose();
  20. _valueBarController = null;
  21. }
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. _ui = null;
  26. }
  27. base.Dispose();
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. packageName = UI_StudioActivityUI.PACKAGE_NAME;
  33. _ui = UI_StudioActivityUI.Create();
  34. this.viewCom = _ui.target;
  35. isfullScreen = true;
  36. isReturnView = true;
  37. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  38. _ui.m_Bg.url = ResPathUtil.GetBgImgPath("bg_fhl");
  39. _ui.m_btnChageLine.url = ResPathUtil.GetCommonGameResPath("zsx_fl");
  40. _ui.m_list.itemRenderer = RenderListItem;
  41. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  42. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  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_LIMIT_CHANGED, OnLimitChanged);
  50. //EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  51. }
  52. protected override void RemoveEventListener()
  53. {
  54. base.RemoveEventListener();
  55. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  56. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  57. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  58. //EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  59. //EventAgent.RemoveEventListener(ConstMessage.STUDIO_FILING_UPDATE, UpdateView);
  60. }
  61. protected override void OnShown()
  62. {
  63. base.OnShown();
  64. _valueBarController.OnShown();
  65. StudioDataManager.Instance.filingChapterId = StudioDataManager.Instance.GetLuckyBoxActivityID();
  66. UpdateView();
  67. UpdateItem();
  68. }
  69. protected override void OnHide()
  70. {
  71. base.OnHide();
  72. _valueBarController.OnHide();
  73. }
  74. private void RenderListItem(int index, GObject obj)
  75. {
  76. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  77. item.m_txtName.text = _storyLevelCfgs[index].name;
  78. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  79. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  80. if (isFight)
  81. {
  82. item.m_loaIcon.visible = false;
  83. item.m_loaItem.visible = true;
  84. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  85. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  86. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  87. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  88. if (item.m_loaItem.data == null)
  89. {
  90. item.m_loaItem.onClick.Add(OnLoaItemClick);
  91. }
  92. item.m_loaItem.data = index;
  93. }
  94. else
  95. {
  96. item.m_loaItem.visible = false;
  97. item.m_loaIcon.visible = true;
  98. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  99. }
  100. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  101. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  102. if (item.m_loaBg.data == null)
  103. {
  104. item.m_loaBg.onClick.Add(OnListItemClick);
  105. }
  106. item.m_loaBg.data = index;
  107. UI_ListLevelItem.ProxyEnd();
  108. }
  109. private void OnLoaItemClick(EventContext context)
  110. {
  111. GObject obj = context.sender as GObject;
  112. int index = (int)obj.data;
  113. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  114. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  115. GoodsItemTipsController.ShowItemTips(itemId);
  116. }
  117. private void OnListItemClick(EventContext context)
  118. {
  119. GObject obj = context.sender as GObject;
  120. int index = (int)obj.data;
  121. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  122. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  123. {
  124. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  125. return;
  126. }
  127. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  128. InstanceZonesController.ShowLevelView(storyLevelCfg.id, OnFinishFilingStoryLevel);
  129. }
  130. private void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  131. {
  132. //StudioDataManager.Instance.SetLuckyBoxActivityID(MainStoryDataManager.currentChapterCfgId);
  133. ViewManager.Show<StudioActivityView>();
  134. }
  135. private void UpdateView()
  136. {
  137. _studioCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  138. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit);
  139. var limitCfg = LimitCfgArray.Instance.GetCfg(this._studioCfg.limit);
  140. _ui.m_loaBg.url = ResPathUtil.GetStudioFilingPicPath(_studioCfg.res); //ResPathUtil.GetBgImgPath(_studioCfg.res);
  141. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
  142. _ui.m_activityTipText.SetVar("name", _studioCfg.name).FlushVars();
  143. _ui.m_activityTitle.text = _studioCfg.name;
  144. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.subType, StudioDataManager.Instance.filingChapterId);
  145. _ui.m_list.numItems = _storyLevelCfgs.Count;
  146. //UpdateRedDot();
  147. }
  148. private void UpdateItem()
  149. {
  150. for (int i = 0; i < _ui.m_list.numChildren; i++)
  151. {
  152. _ui.m_list.GetChildAt(i).visible = false;
  153. }
  154. _itemIndex = 0;
  155. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  156. }
  157. private void AddItemUpdate(object param)
  158. {
  159. _ui.m_list.GetChildAt(_itemIndex).visible = true;
  160. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(_itemIndex));
  161. item.m_Left.Play();
  162. _itemIndex++;
  163. UI_ListLevelItem.ProxyEnd();
  164. }
  165. protected void OnBtnBackClick()
  166. {
  167. Hide();
  168. }
  169. private void OnBtnRewardClick()
  170. {
  171. ViewManager.Show<StudioFilingRewardView>();
  172. }
  173. private void OnLimitChanged(EventContext context)
  174. {
  175. int limitId = (int)context.data;
  176. if (this._studioCfg.limit != limitId)
  177. {
  178. return;
  179. }
  180. UpdateView();
  181. }
  182. }
  183. }