StudioFilingView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 StudioFilingView : BaseWindow
  10. {
  11. private UI_StudioFilingUI _ui;
  12. private ValueBarController _valueBarController;
  13. private StudioCfg _studioCfg;
  14. private List<StoryLevelCfg> _storyLevelCfgs;
  15. private int _viewData = 0;
  16. private int itemIndex = 0;
  17. public override void Dispose()
  18. {
  19. if (_valueBarController != null)
  20. {
  21. _valueBarController.Dispose();
  22. _valueBarController = null;
  23. }
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. _ui = null;
  28. }
  29. base.Dispose();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. packageName = UI_StudioFilingUI.PACKAGE_NAME;
  35. _ui = UI_StudioFilingUI.Create();
  36. this.viewCom = _ui.target;
  37. isfullScreen = true;
  38. isReturnView = true;
  39. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  40. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_fhl");
  41. _ui.m_btnChageLine.url = ResPathUtil.GetCommonGameResPath("zsx_fl");
  42. _ui.m_list.itemRenderer = RenderListItem;
  43. _ui.m_btnBack.onClick.Add(GoBackFrom);
  44. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  45. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  46. _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
  47. _ui.m_btnSuit.onClick.Add(OnBtnSuitClick);
  48. }
  49. protected override void AddEventListener()
  50. {
  51. base.AddEventListener();
  52. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  53. EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  54. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  55. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  56. }
  57. protected override void OnShown()
  58. {
  59. base.OnShown();
  60. _valueBarController.OnShown();
  61. _viewData = this.viewData != null ? (int)this.viewData : 0;
  62. StudioDataManager.Instance.filingChapterId = _viewData > 0 ? _viewData : StudioDataManager.Instance.npcFilingChapterId;
  63. UpdateView();
  64. Timers.inst.AddUpdate(CheckGuide);
  65. UpdateItem();
  66. }
  67. protected override void OnHide()
  68. {
  69. base.OnHide();
  70. _valueBarController.OnHide();
  71. Timers.inst.Remove(CheckGuide);
  72. Timers.inst.Remove(AddItemUpdate);
  73. }
  74. protected void GoBackFrom()
  75. {
  76. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  77. }
  78. protected override void RemoveEventListener()
  79. {
  80. base.RemoveEventListener();
  81. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  82. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  83. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  84. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  85. EventAgent.RemoveEventListener(ConstMessage.STUDIO_FILING_UPDATE, UpdateView);
  86. }
  87. private void OnLimitChanged(EventContext context)
  88. {
  89. int limitId = (int)context.data;
  90. if (this._studioCfg.limit != limitId)
  91. {
  92. return;
  93. }
  94. UpdateView();
  95. }
  96. private void UpdateView()
  97. {
  98. _studioCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  99. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit);
  100. var limitCfg = LimitCfgArray.Instance.GetCfg(this._studioCfg.limit);
  101. _ui.m_btnAdd.visible = limitCfg.itemID > 0;
  102. _ui.m_role.url = ResPathUtil.GetStudioFilingPicPath(_studioCfg.res); //ResPathUtil.GetBgImgPath(_studioCfg.res);
  103. _ui.m_btnChange.title = _studioCfg.name;
  104. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
  105. _ui.m_type.SetSelectedIndex(0);
  106. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  107. _ui.m_txtSuitName.text = suitCfg.name;
  108. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_studioCfg.suitId, out int count, out int totalCount);
  109. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  110. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png");
  111. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.subType, StudioDataManager.Instance.filingChapterId);
  112. _ui.m_list.numItems = _storyLevelCfgs.Count;
  113. UpdateRedDot();
  114. }
  115. private void RenderListItem(int index, GObject obj)
  116. {
  117. // int _index = _storyLevelCfgs.Count - index - 1;
  118. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  119. //item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  120. item.m_txtName.text = _storyLevelCfgs[index].name;
  121. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  122. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  123. //item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  124. if (isFight)
  125. {
  126. //item.m_loaBg.url = "ui://Studio/cyjd_di_1";
  127. item.m_loaIcon.visible = false;
  128. item.m_loaItem.visible = true;
  129. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  130. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  131. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  132. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  133. if (item.m_loaItem.data == null)
  134. {
  135. item.m_loaItem.onClick.Add(OnLoaItemClick);
  136. }
  137. item.m_loaItem.data = index;
  138. }
  139. else
  140. {
  141. //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  142. item.m_loaItem.visible = false;
  143. item.m_loaIcon.visible = true;
  144. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  145. }
  146. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  147. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  148. if (item.m_loaBg.data == null)
  149. {
  150. item.m_loaBg.onClick.Add(OnListItemClick);
  151. }
  152. item.m_loaBg.data = index;
  153. UI_ListLevelItem.ProxyEnd();
  154. }
  155. private void OnListItemClick(EventContext context)
  156. {
  157. GObject obj = context.sender as GObject;
  158. int index = (int)obj.data;
  159. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  160. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  161. {
  162. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  163. return;
  164. }
  165. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  166. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  167. }
  168. private void OnLoaItemClick(EventContext context)
  169. {
  170. GObject obj = context.sender as GObject;
  171. int index = (int)obj.data;
  172. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  173. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  174. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  175. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  176. GoodsItemTipsController.ShowItemTips(itemId);
  177. }
  178. private void OnBtnChangeClick()
  179. {
  180. ViewManager.Show<StudioFilingNpcView>();
  181. }
  182. private void OnBtnRewardClick()
  183. {
  184. ViewManager.Show<StudioFilingRewardView>();
  185. }
  186. private void OnBtnAddClick()
  187. {
  188. ViewManager.Show<StudioBuyNumView>(_studioCfg.limit);
  189. }
  190. private void OnBtnSuitClick()
  191. {
  192. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  193. if (suitCfg.syntheticStoryLevelId > 0 && !InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  194. {
  195. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  196. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  197. return;
  198. }
  199. ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, false);
  200. EventAgent.AddEventListener(ConstMessage.STUDIO_FILING_UPDATE, UpdateView);
  201. //if (_viewData == StudioDataManager.Instance.GetLuckyBoxActivityID())
  202. //{
  203. // int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  204. // ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  205. // long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
  206. // long curTime = TimeHelper.ServerNow();
  207. // if (endTime < curTime) return;
  208. // ViewManager.Show<LuckyBoxActivityView>(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  209. //}
  210. //else
  211. //{
  212. // ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  213. //}
  214. }
  215. private void UpdateRedDot()
  216. {
  217. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  218. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  219. }
  220. private void CheckGuide(object param)
  221. {
  222. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  223. {
  224. UpdateToCheckGuide(null);
  225. }
  226. else
  227. {
  228. Timers.inst.Remove(CheckGuide);
  229. }
  230. }
  231. protected override void UpdateToCheckGuide(object param)
  232. {
  233. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  234. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0);
  235. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  236. }
  237. private void UpdateItem()
  238. {
  239. for (int i = 0; i < _ui.m_list.numChildren; i++)
  240. {
  241. _ui.m_list.GetChildAt(i).visible = false;
  242. }
  243. itemIndex = 0;
  244. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  245. }
  246. private void AddItemUpdate(object param)
  247. {
  248. _ui.m_list.GetChildAt(itemIndex).visible = true;
  249. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  250. item.m_Left.Play();
  251. itemIndex++;
  252. UI_ListLevelItem.ProxyEnd();
  253. }
  254. }
  255. }