TimeTracingLevelView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System;
  2. using System.Collections.Generic;
  3. using cfg.GfgCfg;
  4. using ET;
  5. using FairyGUI;
  6. using UI.CommonGame;
  7. using UI.TimeTracing;
  8. using UnityEngine;
  9. namespace GFGGame
  10. {
  11. public class TimeTracingLevelView : BaseWindow
  12. {
  13. private UI_TimeTracingLevelUI _ui;
  14. private ValueBarController _valueBarController;
  15. private int SuitID;
  16. private int levelId;
  17. private int _chapterID;
  18. long num = 0;
  19. List<CompositebonusCfg> datas;
  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_TimeTracingLevelUI.PACKAGE_NAME;
  38. _ui = UI_TimeTracingLevelUI.Create();
  39. this.viewCom = _ui.target;
  40. isfullScreen = true;
  41. isReturnView = true;
  42. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  43. _ui.m_rankBtn.onClick.Add(OnClickRankBtn);
  44. _ui.m_suitBg.onClick.Add(OnClickMakeSuitBtn);
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. if ((this.viewData as object[]) != null)
  50. {
  51. _chapterID = (int)(this.viewData as object[])[0];
  52. SuitID = (int)(this.viewData as object[])[1];
  53. }
  54. else
  55. {
  56. _chapterID = (int)this.viewData;
  57. }
  58. _ui.m_bg.url = ResPathUtil.GetBgImgPath("chahuibg");
  59. UpdateView();
  60. UpdateSuitNum();
  61. UpdateFirst();
  62. UpdateproBar();
  63. Timers.inst.AddUpdate(CheckGuide);
  64. }
  65. protected override void OnHide()
  66. {
  67. _valueBarController.OnHide();
  68. base.OnHide();
  69. Timers.inst.Remove(CheckGuide);
  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 = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(_chapterID);
  87. var list = StoryLevelConfigManager.GetConfigs(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 =
  111. CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemInfo[levelCfg.Id].HeadItemId);
  112. ItemCfg headBorderCfg =
  113. CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemInfo[levelCfg.Id].HeadBorderItemId);
  114. levelItem.m_player.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.Res);
  115. levelItem.m_player.m_head.url = ResPathUtil.GetHeadPath(headCfg.Res);
  116. RedDotController.Instance.SetComRedDot(levelItem.target,
  117. TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.Id), "", -30, 10);
  118. }
  119. }
  120. else
  121. {
  122. levelItem.m_player.target.visible = false;
  123. }
  124. levelItem.target.onClick.Clear();
  125. levelItem.target.onClick.Add(OnClickLevelItem);
  126. }
  127. else
  128. {
  129. levelItem.target.visible = false;
  130. }
  131. if (!InstanceZonesDataManager.CheckLevelPass(levelCfg.Id))
  132. {
  133. //设置为解锁关卡
  134. RedDotController.Instance.SetComRedDot(levelItem.target,
  135. TimeTracingDataManager.Instance.GetLevelRewardStatus(levelCfg.Id), "", -30, 10);
  136. MainStoryDataManager.currentLevelCfgId = levelCfg.Id;
  137. levelItem.m_player.target.visible = false;
  138. }
  139. UI_TimeTracingLevelItem.ProxyEnd();
  140. }
  141. _valueBarController.UpdateList(new List<int>() { ConstItemID.DIAMOND_PURPLE, ConstItemID.DIAMOND_RED });
  142. }
  143. private void UpdateSuitNum()
  144. {
  145. SuitCfg suitCfg =CommonDataManager.Tables.TblSuitCfg.GetOrDefault(SuitID);
  146. _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.Res, "png");
  147. int count;
  148. int totalCount;
  149. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(SuitID, out count, out totalCount);
  150. _ui.m_suitNum.text = count + "/" + totalCount;
  151. }
  152. private void UpdateFirst()
  153. {
  154. if (TimeTracingDataManager.Instance.SuitRankDatasDic[0].Count == 0)
  155. {
  156. _ui.m_playerName.text = "";
  157. _ui.m_headFrame.url = "";
  158. _ui.m_headIcon.url = "";
  159. }
  160. else
  161. {
  162. _ui.m_playerName.text = TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].RoleName;
  163. ItemCfg headCfg =
  164. CommonDataManager.Tables.TblItemCfg.GetOrDefault(TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadItemId);
  165. ItemCfg headBorderCfg =
  166. CommonDataManager.Tables.TblItemCfg.GetOrDefault(
  167. TimeTracingDataManager.Instance.SuitRankDatasDic[0][0].HeadBorderItemId);
  168. _ui.m_headFrame.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.Res);
  169. _ui.m_headIcon.url = ResPathUtil.GetHeadPath(headCfg.Res);
  170. }
  171. }
  172. private void UpdateproBar()
  173. {
  174. int consumeID = 0;
  175. datas =CommonDataManager.Tables.TblCompositebonusCfg.GetGroup1ByChapterId(_chapterID) ;
  176. consumeID = datas[0].Params1[0];
  177. ItemData item;
  178. if (BagDataManager.Instance.GetBagData().TryGetValue(consumeID, out item))
  179. {
  180. _ui.m_countNum.text = item.num.ToString();
  181. num = item.num;
  182. }
  183. else
  184. {
  185. num = 0;
  186. _ui.m_countNum.text = "0";
  187. }
  188. _ui.m_proBar.max = datas[datas.Count - 1].Count;
  189. _ui.m_proBar.value = num;
  190. UpdateproBarItem();
  191. }
  192. private void UpdateproBarItem()
  193. {
  194. for (int i = 0; i < datas.Count; i++)
  195. {
  196. GComponent comProBonus = _ui.target.GetChild("barItem" + i).asCom;
  197. if (i == datas.Count - 1)
  198. {
  199. comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
  200. 30;
  201. }
  202. else
  203. {
  204. comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
  205. 15;
  206. }
  207. UI_proBarItem item = UI_proBarItem.Proxy(comProBonus);
  208. //if (num >= datas[i].count)
  209. //{
  210. // return;
  211. //}
  212. //else
  213. //{
  214. //}
  215. item.m_c1.selectedIndex =
  216. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]);
  217. RedDotController.Instance.SetComRedDot(item.target,
  218. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]) == 1,
  219. "", -10, 25);
  220. ItemCfg itemcfg =CommonDataManager.Tables.TblItemCfg.GetOrDefault(datas[i].Bonus[0].ItemId);
  221. if (itemcfg.ItemType == ConstItemType.HEAD)
  222. {
  223. item.m_icon.url = ResPathUtil.GetHeadBorderPath(itemcfg.Res);
  224. }
  225. else
  226. {
  227. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg.Res, "png");
  228. }
  229. item.m_count.text = datas[i].Count.ToString();
  230. if (item.target.data == null)
  231. {
  232. item.target.onClick.Add(OnBtnGetProBonus);
  233. }
  234. item.target.data = datas[i];
  235. UI_proBarItem.ProxyEnd();
  236. }
  237. }
  238. private async void OnBtnGetProBonus(EventContext context)
  239. {
  240. GObject obj = context.sender as GObject;
  241. CompositebonusCfg compositeCfg = obj.data as CompositebonusCfg;
  242. if (num < compositeCfg.Count ||
  243. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(compositeCfg.Id, compositeCfg.Params1[0]) !=
  244. 1)
  245. {
  246. GoodsItemTipsController.ShowItemTips(compositeCfg.Bonus[0].ItemId);
  247. return;
  248. }
  249. await TimeTracingSProxy.ReqGetSuitReward(compositeCfg.Id);
  250. UpdateproBarItem();
  251. }
  252. private async void OnClickRankBtn()
  253. {
  254. await TimeTracingSProxy.ReqGetSuitFriendRank(SuitID);
  255. ViewManager.Show<TimeTracingSuitRankView>(new object[] { SuitID });
  256. }
  257. private void OnClickMakeSuitBtn()
  258. {
  259. ViewManager.Show<ClothingSyntheticView>(new object[] { SuitID, 0, _chapterID }, false, false);
  260. }
  261. private void OnClickLevelItem(EventContext context)
  262. {
  263. GObject obj = context.sender as GObject;
  264. StoryLevelCfg storyLevelCfg = (StoryLevelCfg)obj.data;
  265. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.Id;
  266. InstanceZonesController.ShowLevelView(storyLevelCfg.Id,
  267. StudioDataManager.Instance.OnFinishTimeTracingLevel);
  268. }
  269. private void OnClickBtnBack()
  270. {
  271. ViewManager.GoBackFrom(typeof(TimeTracingLevelView).FullName);
  272. }
  273. private void CheckGuide(object param)
  274. {
  275. GRoot.inst.touchable = true;
  276. if (GuideDataManager.IsGuideFinish("TimeTracingShowView") <= 0)
  277. UpdateCheckGuide(null);
  278. else
  279. Timers.inst.Remove(CheckGuide);
  280. }
  281. protected void UpdateCheckGuide(object param)
  282. {
  283. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  284. GuideController.TryGuide(_ui.m_level1.target, "TimeTracingShowView", 5, "挑战。", -1, true, 0, false, false,
  285. true);
  286. GuideController.TryGuide(_ui.m_btnBack, "TimeTracingShowView", 6, "返回。", -1, true, 0, false, false, true);
  287. }
  288. }
  289. }