StudioFilingView.cs 12 KB

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