StudioFilingView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. }
  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_role.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. _ui.m_type.SetSelectedIndex(0);
  105. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  106. _ui.m_txtSuitName.text = suitCfg.name;
  107. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_studioCfg.suitId, out int count, out int totalCount);
  108. _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount);
  109. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png");
  110. _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.subType, StudioDataManager.Instance.filingChapterId);
  111. _ui.m_list.numItems = _storyLevelCfgs.Count;
  112. UpdateRedDot();
  113. }
  114. private void RenderListItem(int index, GObject obj)
  115. {
  116. // int _index = _storyLevelCfgs.Count - index - 1;
  117. UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj);
  118. //item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1;
  119. item.m_txtName.text = _storyLevelCfgs[index].name;
  120. bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID);
  121. string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2";
  122. //item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg);
  123. if (isFight)
  124. {
  125. //item.m_loaBg.url = "ui://Studio/cyjd_di_1";
  126. item.m_loaIcon.visible = false;
  127. item.m_loaItem.visible = true;
  128. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  129. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  130. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  131. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  132. if (item.m_loaItem.data == null)
  133. {
  134. item.m_loaItem.onClick.Add(OnLoaItemClick);
  135. }
  136. item.m_loaItem.data = index;
  137. }
  138. else
  139. {
  140. //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  141. item.m_loaItem.visible = false;
  142. item.m_loaIcon.visible = true;
  143. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  144. }
  145. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  146. item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  147. if (item.m_loaBg.data == null)
  148. {
  149. item.m_loaBg.onClick.Add(OnListItemClick);
  150. }
  151. item.m_loaBg.data = index;
  152. UI_ListLevelItem.ProxyEnd();
  153. }
  154. private void OnListItemClick(EventContext context)
  155. {
  156. GObject obj = context.sender as GObject;
  157. int index = (int)obj.data;
  158. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  159. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  160. {
  161. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  162. return;
  163. }
  164. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  165. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  166. }
  167. private void OnLoaItemClick(EventContext context)
  168. {
  169. GObject obj = context.sender as GObject;
  170. int index = (int)obj.data;
  171. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  172. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  173. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  174. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  175. GoodsItemTipsController.ShowItemTips(itemId);
  176. }
  177. private void OnBtnChangeClick()
  178. {
  179. ViewManager.Show<StudioFilingNpcView>();
  180. }
  181. private void OnBtnRewardClick()
  182. {
  183. ViewManager.Show<StudioFilingRewardView>();
  184. }
  185. private void OnBtnAddClick()
  186. {
  187. ViewManager.Show<StudioBuyNumView>(_studioCfg.limit);
  188. }
  189. private void OnBtnSuitClick()
  190. {
  191. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  192. if (suitCfg.syntheticStoryLevelId > 0 && !InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  193. {
  194. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  195. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  196. return;
  197. }
  198. ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, false);
  199. //if (_viewData == StudioDataManager.Instance.GetLuckyBoxActivityID())
  200. //{
  201. // int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  202. // ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  203. // long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
  204. // long curTime = TimeHelper.ServerNow();
  205. // if (endTime < curTime) return;
  206. // ViewManager.Show<LuckyBoxActivityView>(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  207. //}
  208. //else
  209. //{
  210. // ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  211. //}
  212. }
  213. private void UpdateRedDot()
  214. {
  215. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  216. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false));
  217. }
  218. private void CheckGuide(object param)
  219. {
  220. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  221. {
  222. UpdateToCheckGuide(null);
  223. }
  224. else
  225. {
  226. Timers.inst.Remove(CheckGuide);
  227. }
  228. }
  229. protected override void UpdateToCheckGuide(object param)
  230. {
  231. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  232. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0);
  233. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  234. }
  235. private void UpdateItem()
  236. {
  237. for (int i = 0; i < _ui.m_list.numChildren; i++)
  238. {
  239. _ui.m_list.GetChildAt(i).visible = false;
  240. }
  241. itemIndex = 0;
  242. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  243. }
  244. private void AddItemUpdate(object param)
  245. {
  246. _ui.m_list.GetChildAt(itemIndex).visible = true;
  247. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  248. item.m_Left.Play();
  249. itemIndex++;
  250. UI_ListLevelItem.ProxyEnd();
  251. }
  252. }
  253. }