StudioActivityView.cs 8.0 KB

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