StudioFilingView.cs 12 KB

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