StudioActivityView.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. _valueBarController.UpdateList(new List<int>() { 3000015, ConstItemID.GOLD, ConstItemID.DIAMOND_RED });
  67. StudioDataManager.Instance.filingChapterId = StudioDataManager.Instance.GetLuckyBoxActivityID();
  68. UpdateView();
  69. UpdateItem();
  70. }
  71. protected override void OnHide()
  72. {
  73. base.OnHide();
  74. _valueBarController.OnHide();
  75. }
  76. private void RenderListItem(int index, GObject obj)
  77. {
  78. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  79. item.m_txtName.text = _storyLevelCfgs[index].name;
  80. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  81. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  82. if (isFight)
  83. {
  84. item.m_loaIcon.visible = false;
  85. item.m_loaItem.visible = true;
  86. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  87. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  88. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  89. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  90. if (item.m_loaItem.data == null)
  91. {
  92. item.m_loaItem.onClick.Add(OnLoaItemClick);
  93. }
  94. item.m_loaItem.data = index;
  95. }
  96. else
  97. {
  98. item.m_loaItem.visible = false;
  99. item.m_loaIcon.visible = true;
  100. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  101. }
  102. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  103. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  104. if (item.m_loaBg.data == null)
  105. {
  106. item.m_loaBg.onClick.Add(OnListItemClick);
  107. }
  108. item.m_loaBg.data = index;
  109. UI_ListLevelItem.ProxyEnd();
  110. }
  111. private void OnLoaItemClick(EventContext context)
  112. {
  113. GObject obj = context.sender as GObject;
  114. int index = (int)obj.data;
  115. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  116. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  117. GoodsItemTipsController.ShowItemTips(itemId);
  118. }
  119. private void OnListItemClick(EventContext context)
  120. {
  121. GObject obj = context.sender as GObject;
  122. int index = (int)obj.data;
  123. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  124. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  125. {
  126. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  127. return;
  128. }
  129. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  130. InstanceZonesController.ShowLevelView(storyLevelCfg.id, OnFinishFilingStoryLevel);
  131. }
  132. private void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  133. {
  134. //StudioDataManager.Instance.SetLuckyBoxActivityID(MainStoryDataManager.currentChapterCfgId);
  135. ViewManager.Show<StudioActivityView>();
  136. }
  137. private void UpdateView()
  138. {
  139. _studioCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  140. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit);
  141. var limitCfg = LimitCfgArray.Instance.GetCfg(this._studioCfg.limit);
  142. _ui.m_loaBg.url = ResPathUtil.GetStudioFilingPicPath(_studioCfg.res); //ResPathUtil.GetBgImgPath(_studioCfg.res);
  143. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
  144. _ui.m_activityTipText.SetVar("name", _studioCfg.name).FlushVars();
  145. _ui.m_activityTitle.text = _studioCfg.name;
  146. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.subType, StudioDataManager.Instance.filingChapterId);
  147. _ui.m_list.numItems = _storyLevelCfgs.Count;
  148. //UpdateRedDot();
  149. }
  150. private void UpdateItem()
  151. {
  152. for (int i = 0; i < _ui.m_list.numChildren; i++)
  153. {
  154. _ui.m_list.GetChildAt(i).visible = false;
  155. }
  156. _itemIndex = 0;
  157. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  158. }
  159. private void AddItemUpdate(object param)
  160. {
  161. _ui.m_list.GetChildAt(_itemIndex).visible = true;
  162. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(_itemIndex));
  163. item.m_Left.Play();
  164. _itemIndex++;
  165. UI_ListLevelItem.ProxyEnd();
  166. }
  167. protected void OnBtnBackClick()
  168. {
  169. Hide();
  170. }
  171. private void OnBtnRewardClick()
  172. {
  173. ViewManager.Show<StudioFilingRewardView>();
  174. }
  175. private void OnLimitChanged(EventContext context)
  176. {
  177. int limitId = (int)context.data;
  178. if (this._studioCfg.limit != limitId)
  179. {
  180. return;
  181. }
  182. UpdateView();
  183. }
  184. }
  185. }