TimeTracingLevelView.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.CommonGame;
  6. using UI.TimeTracing;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class TimeTracingLevelView : BaseWindow
  11. {
  12. private UI_TimeTracingLevelUI _ui;
  13. private ValueBarController _valueBarController;
  14. private int SuitID;
  15. private int levelId;
  16. private int _chapterID;
  17. long num = 0;
  18. List<CompositebonusCfg> datas;
  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_TimeTracingLevelUI.PACKAGE_NAME;
  37. _ui = UI_TimeTracingLevelUI.Create();
  38. this.viewCom = _ui.target;
  39. isfullScreen = true;
  40. isReturnView = true;
  41. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  42. _ui.m_rankBtn.onClick.Add(OnClickRankBtn);
  43. _ui.m_suitBg.onClick.Add(OnClickMakeSuitBtn);
  44. }
  45. protected async override void OnShown()
  46. {
  47. base.OnShown();
  48. if ((this.viewData as object[]) != null)
  49. {
  50. _chapterID = (int)(this.viewData as object[])[0];
  51. SuitID = (int)(this.viewData as object[])[1];
  52. }
  53. else
  54. {
  55. _chapterID = (int)this.viewData;
  56. }
  57. _ui.m_bg.url = ResPathUtil.GetBgImgPath("chahuibg");
  58. UpdateView();
  59. ViewManager.Show<ModalStatusView>("请求中...");
  60. await ReqGetSuitRank();
  61. ViewManager.Hide<ModalStatusView>();
  62. UpdateSuitNum();
  63. UpdateFirst();
  64. UpdateproBar();
  65. }
  66. protected override void OnHide()
  67. {
  68. _valueBarController.OnHide();
  69. base.OnHide();
  70. }
  71. protected override void AddEventListener()
  72. {
  73. base.AddEventListener();
  74. EventAgent.AddEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateView);
  75. }
  76. protected override void RemoveEventListener()
  77. {
  78. base.RemoveEventListener();
  79. EventAgent.RemoveEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateView);
  80. }
  81. private void UpdateView()
  82. {
  83. MainStoryDataManager.currentChapterCfgId = _chapterID;
  84. _valueBarController = new ValueBarController(_ui.m_moneyList);
  85. _valueBarController.OnShown();
  86. ActivityFightCfg chapterCfg = ActivityFightCfgArray.Instance.GetCfg(_chapterID);
  87. var list = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(chapterCfg.type, chapterCfg.subType, chapterCfg.id);
  88. for (int i = 0; i < 5; i++)
  89. {
  90. int j = i + 1;
  91. GObject obj = _ui.target.GetChild("level" + j.ToString());
  92. StoryLevelCfg levelCfg = i < list.Count ? list[i] : null;
  93. UI_TimeTracingLevelItem levelItem = UI_TimeTracingLevelItem.Proxy(obj);
  94. if (i == 0 || InstanceZonesDataManager.CheckLevelPass(levelCfg.id - 1))
  95. {
  96. levelItem.target.data = levelCfg;
  97. levelItem.target.visible = true;
  98. levelItem.m_levelName.text = levelCfg.name;
  99. Dictionary<int, LevelRoleInfoProto> itemInfo;
  100. if (TimeTracingDataManager._LevelMaxInfoDic.TryGetValue(_chapterID,out itemInfo))
  101. {
  102. if(itemInfo.Count <= i)
  103. {
  104. levelItem.m_player.target.visible = false;
  105. }
  106. else
  107. {
  108. levelItem.m_player.target.visible = true;
  109. levelItem.m_player.m_name.text = itemInfo[levelCfg.id].RoleName;
  110. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(itemInfo[levelCfg.id].HeadItemId);
  111. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(itemInfo[levelCfg.id].HeadBorderItemId);
  112. levelItem.m_player.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  113. levelItem.m_player.m_head.url = ResPathUtil.GetHeadPath(headCfg.res);
  114. RedDotController.Instance.SetComRedDot(levelItem.target, TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.id), "", -30);
  115. }
  116. }
  117. else
  118. {
  119. levelItem.m_player.target.visible = false;
  120. }
  121. levelItem.target.onClick.Clear();
  122. levelItem.target.onClick.Add(OnClickLevelItem);
  123. }
  124. else
  125. {
  126. levelItem.target.visible = false;
  127. }
  128. if (!InstanceZonesDataManager.CheckLevelPass(levelCfg.id))
  129. {
  130. //设置为解锁关卡
  131. RedDotController.Instance.SetComRedDot(levelItem.target, TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.id),"",-30);
  132. MainStoryDataManager.currentLevelCfgId = levelCfg.id;
  133. levelItem.m_player.target.visible = false;
  134. }
  135. UI_TimeTracingLevelItem.ProxyEnd();
  136. }
  137. _valueBarController.UpdateList(new List<int>() { ConstItemID.DIAMOND_PURPLE, ConstItemID.DIAMOND_RED });
  138. }
  139. private void UpdateSuitNum()
  140. {
  141. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(SuitID);
  142. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png");
  143. int count;
  144. int totalCount;
  145. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(SuitID, out count, out totalCount);
  146. _ui.m_suitNum.text = count + "/" + totalCount;
  147. }
  148. private void UpdateFirst()
  149. {
  150. if(TimeTracingDataManager.Instance.SuitRankDatasDic[0].Count == 0)
  151. {
  152. _ui.m_playerName.text = "";
  153. _ui.m_headFrame.url = "";
  154. _ui.m_headIcon.url = "";
  155. }
  156. else
  157. {
  158. _ui.m_playerName.text = TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].RoleName;
  159. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadItemId);
  160. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadBorderItemId);
  161. _ui.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  162. _ui.m_headIcon.url = ResPathUtil.GetHeadPath(headCfg.res);
  163. }
  164. }
  165. private void UpdateproBar()
  166. {
  167. int consumeID = 0;
  168. datas = CompositebonusCfgArray.Instance.GetCfgsBychapterId(_chapterID);
  169. consumeID = datas[0].paramsArr[0];
  170. ItemData item;
  171. if (BagDataManager.Instance.GetBagData().TryGetValue(consumeID, out item))
  172. {
  173. _ui.m_countNum.text = item.num.ToString();
  174. num = item.num;
  175. }
  176. else
  177. {
  178. num = 0;
  179. _ui.m_countNum.text = "0";
  180. }
  181. _ui.m_proBar.max = datas[datas.Count-1].count;
  182. _ui.m_proBar.value = num;
  183. UpdateproBarItem();
  184. }
  185. private void UpdateproBarItem()
  186. {
  187. for (int i = 0; i < datas.Count; i++)
  188. {
  189. GComponent comProBonus = _ui.target.GetChild("barItem" + i).asCom;
  190. if (i == datas.Count - 1)
  191. {
  192. comProBonus.x = ((float)datas[i].count / (float)datas[datas.Count - 1].count) * _ui.m_proBar.width - 30;
  193. }
  194. else
  195. {
  196. comProBonus.x = ((float)datas[i].count / (float)datas[datas.Count - 1].count) * _ui.m_proBar.width - 15;
  197. }
  198. UI_proBarItem item = UI_proBarItem.Proxy(comProBonus);
  199. //if (num >= datas[i].count)
  200. //{
  201. // return;
  202. //}
  203. //else
  204. //{
  205. //}
  206. item.m_c1.selectedIndex = TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].id, datas[i].paramsArr[0]);
  207. if (item.target.data == null)
  208. {
  209. item.target.onClick.Add(OnBtnGetProBonus);
  210. }
  211. item.target.data = datas[i];
  212. UI_proBarItem.ProxyEnd();
  213. }
  214. }
  215. private async void OnBtnGetProBonus(EventContext context)
  216. {
  217. GObject obj = context.sender as GObject;
  218. CompositebonusCfg compositeCfg = obj.data as CompositebonusCfg;
  219. if(num < compositeCfg.count || TimeTracingDataManager.Instance.GetChapterRewardIDStatus(compositeCfg.id, compositeCfg.paramsArr[0]) != 1)
  220. {
  221. return;
  222. }
  223. await TimeTracingSProxy.ReqGetSuitReward(compositeCfg.id);
  224. UpdateproBarItem();
  225. }
  226. private async void OnClickRankBtn()
  227. {
  228. await TimeTracingSProxy.ReqGetSuitRank(SuitID);
  229. await TimeTracingSProxy.ReqGetSuitFriendRank(SuitID);
  230. ViewManager.Show<TimeTracingSuitRankView>(new object[] { SuitID });
  231. }
  232. private void OnClickMakeSuitBtn()
  233. {
  234. ViewManager.Show<ClothingSyntheticView>(new object[] { SuitID, 0, _chapterID }, false, false);
  235. }
  236. private void OnClickLevelItem(EventContext context)
  237. {
  238. GObject obj = context.sender as GObject;
  239. StoryLevelCfg storyLevelCfg = (StoryLevelCfg)obj.data;
  240. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id;
  241. InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishTimeTracingLevel);
  242. }
  243. private void OnClickBtnBack()
  244. {
  245. ViewManager.GoBackFrom(typeof(TimeTracingLevelView).FullName);
  246. }
  247. private async ETTask ReqGetSuitRank()
  248. {
  249. await TimeTracingSProxy.ReqGetSuitRank(SuitID);
  250. await TimeTracingSProxy.ReqGetSuitFriendRank(SuitID);
  251. await TimeTracingSProxy.ReqGetSuitRewardStatus();
  252. await TimeTracingSProxy.ReqGetLevelRewardStatus();
  253. }
  254. }
  255. }