StudioFilingView.cs 13 KB

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