StudioFilingView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. private List<string> nameString = new List<string> { "壹", "贰", "叁", "肆", "伍" };
  18. public override void Dispose()
  19. {
  20. if (_valueBarController != null)
  21. {
  22. _valueBarController.Dispose();
  23. _valueBarController = null;
  24. }
  25. if (_ui != null)
  26. {
  27. _ui.Dispose();
  28. _ui = null;
  29. }
  30. base.Dispose();
  31. }
  32. protected override void OnInit()
  33. {
  34. base.OnInit();
  35. packageName = UI_StudioFilingUI.PACKAGE_NAME;
  36. _ui = UI_StudioFilingUI.Create();
  37. this.viewCom = _ui.target;
  38. isfullScreen = true;
  39. isReturnView = true;
  40. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  41. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
  42. _ui.m_btnChageLine.url = ResPathUtil.GetCommonGameResPath("zsx_fl");
  43. _ui.m_list.itemRenderer = RenderListItem;
  44. _ui.m_btnBack.onClick.Add(GoBackFrom);
  45. _ui.m_btnChange.onClick.Add(OnBtnChangeClick);
  46. _ui.m_btnReward.onClick.Add(OnBtnRewardClick);
  47. _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
  48. _ui.m_btnSuit.onClick.Add(OnBtnSuitClick);
  49. }
  50. protected override void AddEventListener()
  51. {
  52. base.AddEventListener();
  53. EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  54. EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  55. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  56. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  57. }
  58. protected override void OnShown()
  59. {
  60. base.OnShown();
  61. _valueBarController.OnShown();
  62. _viewData = this.viewData != null ? (int)this.viewData : 0;
  63. StudioDataManager.Instance.filingChapterId = _viewData > 0 ? _viewData : StudioDataManager.Instance.npcFilingChapterId;
  64. UpdateView();
  65. Timers.inst.AddUpdate(CheckGuide);
  66. UpdateItem();
  67. }
  68. protected override void OnHide()
  69. {
  70. base.OnHide();
  71. _valueBarController.OnHide();
  72. Timers.inst.Remove(CheckGuide);
  73. Timers.inst.Remove(AddItemUpdate);
  74. }
  75. protected void GoBackFrom()
  76. {
  77. ViewManager.GoBackFrom(typeof(StudioFilingView).FullName);
  78. }
  79. protected override void RemoveEventListener()
  80. {
  81. base.RemoveEventListener();
  82. EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView);
  83. EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView);
  84. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);
  85. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  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.icon = "ui://Studio/gzs_" + _studioCfg.res;
  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 + "-" + nameString[index];
  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_flow.visible = true;
  128. item.m_loaIcon.visible = false;
  129. item.m_loaItem.visible = true;
  130. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  131. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  132. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  133. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  134. if (item.m_loaItem.data == null)
  135. {
  136. item.m_loaItem.onClick.Add(OnLoaItemClick);
  137. }
  138. item.m_loaItem.data = index;
  139. }
  140. else
  141. {
  142. //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  143. item.m_flow.visible = false;
  144. item.m_loaItem.visible = false;
  145. item.m_loaIcon.visible = true;
  146. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.res);
  147. }
  148. item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id);
  149. item.m_comFlower.m_c1.selectedIndex = 0;//InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  150. item.m_c2.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  151. if (item.m_loaBg.data == null)
  152. {
  153. item.m_loaBg.onClick.Add(OnListItemClick);
  154. }
  155. item.m_loaBg.data = index;
  156. UI_ListLevelItem.ProxyEnd();
  157. }
  158. private void OnListItemClick(EventContext context)
  159. {
  160. GObject obj = context.sender as GObject;
  161. int index = (int)obj.data;
  162. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  163. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id))
  164. {
  165. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  166. return;
  167. }
  168. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  169. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel);
  170. }
  171. private void OnLoaItemClick(EventContext context)
  172. {
  173. GObject obj = context.sender as GObject;
  174. int index = (int)obj.data;
  175. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  176. int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item;
  177. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  178. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  179. GoodsItemTipsController.ShowItemTips(itemId);
  180. }
  181. private void OnBtnChangeClick()
  182. {
  183. ViewManager.Show<StudioFilingNpcView>();
  184. }
  185. private void OnBtnRewardClick()
  186. {
  187. ViewManager.Show<StudioFilingRewardView>();
  188. }
  189. private void OnBtnAddClick()
  190. {
  191. ViewManager.Show<StudioBuyNumView>(_studioCfg.limit);
  192. }
  193. private void OnBtnSuitClick()
  194. {
  195. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId);
  196. if (suitCfg.syntheticStoryLevelId > 0 && !InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId))
  197. {
  198. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  199. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name));
  200. return;
  201. }
  202. ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, false);
  203. //if (_viewData == StudioDataManager.Instance.GetLuckyBoxActivityID())
  204. //{
  205. // int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  206. // ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  207. // long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
  208. // long curTime = TimeHelper.ServerNow();
  209. // if (endTime < curTime) return;
  210. // ViewManager.Show<LuckyBoxActivityView>(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  211. //}
  212. //else
  213. //{
  214. // ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  215. //}
  216. }
  217. private void UpdateRedDot()
  218. {
  219. RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  220. RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false),"",-27);
  221. }
  222. private void CheckGuide(object param)
  223. {
  224. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  225. {
  226. UpdateToCheckGuide(null);
  227. }
  228. else
  229. {
  230. Timers.inst.Remove(CheckGuide);
  231. }
  232. }
  233. protected override void UpdateToCheckGuide(object param)
  234. {
  235. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  236. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0);
  237. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  238. }
  239. private void UpdateItem()
  240. {
  241. for (int i = 0; i < _ui.m_list.numChildren; i++)
  242. {
  243. _ui.m_list.GetChildAt(i).visible = false;
  244. }
  245. itemIndex = 0;
  246. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  247. }
  248. private void AddItemUpdate(object param)
  249. {
  250. _ui.m_list.GetChildAt(itemIndex).visible = true;
  251. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  252. item.m_Left.Play();
  253. itemIndex++;
  254. UI_ListLevelItem.ProxyEnd();
  255. }
  256. }
  257. }