StudioFilingView.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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.GetGroup1ById(storyFightCfg.BonusRandom[0])[0].Item;
  141. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemId);
  142. item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg);
  143. if (item.m_loaItem.data == null)
  144. {
  145. item.m_loaItem.onClick.Add(OnLoaItemClick);
  146. }
  147. item.m_loaItem.data = index;
  148. }
  149. else
  150. {
  151. //item.m_loaBg.url = "ui://Studio/cyjd_di_2";
  152. item.m_flow.visible = false;
  153. item.m_loaItem.visible = false;
  154. item.m_loaIcon.visible = true;
  155. item.m_loaIcon.url = string.Format("ui://Studio/{0}", _studioCfg.Res);
  156. }
  157. item.m_grpLock.visible =
  158. index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].Id);
  159. item.m_comFlower.m_c1.selectedIndex =
  160. 0; //InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id);
  161. item.m_c2.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].Id);
  162. if (item.m_loaBg.data == null)
  163. {
  164. item.m_loaBg.onClick.Add(OnListItemClick);
  165. }
  166. item.m_loaBg.data = index;
  167. UI_ListLevelItem.ProxyEnd();
  168. }
  169. private void OnListItemClick(EventContext context)
  170. {
  171. GObject obj = context.sender as GObject;
  172. int index = (int)obj.data;
  173. StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index];
  174. if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].Id))
  175. {
  176. PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
  177. return;
  178. }
  179. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.Id;
  180. InstanceZonesController.ShowLevelView(storyLevelCfg.Id,
  181. StudioDataManager.Instance.OnFinishFilingStoryLevel);
  182. }
  183. private void OnLoaItemClick(EventContext context)
  184. {
  185. GObject obj = context.sender as GObject;
  186. int index = (int)obj.data;
  187. StoryFightCfg storyFightCfg =
  188. CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(_storyLevelCfgs[index].FightID));
  189. int itemId = CommonDataManager.Tables.TblDropOutCfg.GetGroup1ById(storyFightCfg.BonusRandom[0])[0].Item;
  190. // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID);
  191. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]);
  192. GoodsItemTipsController.ShowItemTips(itemId);
  193. }
  194. private void OnBtnChangeClick()
  195. {
  196. ViewManager.Show<StudioFilingNpcView>();
  197. }
  198. private void OnBtnRewardClick()
  199. {
  200. ViewManager.Show<StudioFilingRewardView>();
  201. }
  202. private void OnBtnAddClick()
  203. {
  204. ViewManager.Show<StudioBuyNumView>(_studioCfg.Limit);
  205. }
  206. private void OnBtnSuitClick()
  207. {
  208. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_studioCfg.SuitId);
  209. if (suitCfg.SyntheticStoryLevelId > 0 &&
  210. !InstanceZonesDataManager.CheckLevelPass(suitCfg.SyntheticStoryLevelId))
  211. {
  212. StoryLevelCfg cfg =
  213. CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(suitCfg.SyntheticStoryLevelId);
  214. PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.Name));
  215. return;
  216. }
  217. ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.SuitId }, false);
  218. //if (_viewData == StudioDataManager.Instance.GetLuckyBoxActivityID())
  219. //{
  220. // int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  221. // ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
  222. // long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
  223. // long curTime = TimeHelper.ServerNow();
  224. // if (endTime < curTime) return;
  225. // ViewManager.Show<LuckyBoxActivityView>(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  226. //}
  227. //else
  228. //{
  229. // ViewManager.Show<ClothingSyntheticView>(new object[] { _studioCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, false);
  230. //}
  231. }
  232. private void UpdateRedDot()
  233. {
  234. RedDotController.Instance.SetComRedDot(_ui.m_btnReward,
  235. StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId));
  236. RedDotController.Instance.SetComRedDot(_ui.m_btnChange,
  237. RedDotDataManager.Instance.GetStudioFilingRed(false), "", -27);
  238. }
  239. private void CheckGuide(object param)
  240. {
  241. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0)
  242. {
  243. UpdateToCheckGuide(null);
  244. }
  245. else
  246. {
  247. Timers.inst.Remove(CheckGuide);
  248. }
  249. }
  250. protected override void UpdateToCheckGuide(object param)
  251. {
  252. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  253. GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0);
  254. GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5);
  255. }
  256. private void UpdateItem()
  257. {
  258. for (int i = 0; i < _ui.m_list.numChildren; i++)
  259. {
  260. _ui.m_list.GetChildAt(i).visible = false;
  261. }
  262. itemIndex = 0;
  263. Timers.inst.Add(0.05f, _ui.m_list.numChildren, AddItemUpdate, 1);
  264. }
  265. private void AddItemUpdate(object param)
  266. {
  267. _ui.m_list.GetChildAt(itemIndex).visible = true;
  268. UI_ListLevelItem item = UI_ListLevelItem.Proxy(_ui.m_list.GetChildAt(itemIndex));
  269. item.m_Left.Play();
  270. itemIndex++;
  271. UI_ListLevelItem.ProxyEnd();
  272. }
  273. }
  274. }