StudioFilingView.cs 12 KB

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