TimeTracingLevelView.cs 12 KB

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