TimeTracingLevelView.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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.DataList.Where(a => a.ChapterId == _chapterID)
  182. .ToList();
  183. consumeID = datas[0].Params1[0];
  184. ItemData item;
  185. if (BagDataManager.Instance.GetBagData().TryGetValue(consumeID, out item))
  186. {
  187. _ui.m_countNum.text = item.num.ToString();
  188. num = item.num;
  189. }
  190. else
  191. {
  192. num = 0;
  193. _ui.m_countNum.text = "0";
  194. }
  195. _ui.m_proBar.max = datas[datas.Count - 1].Count;
  196. _ui.m_proBar.value = num;
  197. UpdateproBarItem();
  198. }
  199. private void UpdateproBarItem()
  200. {
  201. for (int i = 0; i < datas.Count; i++)
  202. {
  203. GComponent comProBonus = _ui.target.GetChild("barItem" + i).asCom;
  204. if (i == datas.Count - 1)
  205. {
  206. comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
  207. 30;
  208. }
  209. else
  210. {
  211. comProBonus.x = ((float)datas[i].Count / (float)datas[datas.Count - 1].Count) * _ui.m_proBar.width -
  212. 15;
  213. }
  214. UI_proBarItem item = UI_proBarItem.Proxy(comProBonus);
  215. //if (num >= datas[i].count)
  216. //{
  217. // return;
  218. //}
  219. //else
  220. //{
  221. //}
  222. item.m_c1.selectedIndex =
  223. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]);
  224. RedDotController.Instance.SetComRedDot(item.target,
  225. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(datas[i].Id, datas[i].Params1[0]) == 1,
  226. "", -10, 25);
  227. ItemCfg itemcfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(datas[i].Bonus[0].ItemId);
  228. if (itemcfg.ItemType == ConstItemType.HEAD)
  229. {
  230. item.m_icon.url = ResPathUtil.GetHeadBorderPath(itemcfg.Res);
  231. }
  232. else
  233. {
  234. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg.Res, "png");
  235. }
  236. item.m_count.text = datas[i].Count.ToString();
  237. if (item.target.data == null)
  238. {
  239. item.target.onClick.Add(OnBtnGetProBonus);
  240. }
  241. item.target.data = datas[i];
  242. UI_proBarItem.ProxyEnd();
  243. }
  244. }
  245. private async void OnBtnGetProBonus(EventContext context)
  246. {
  247. GObject obj = context.sender as GObject;
  248. CompositebonusCfg compositeCfg = obj.data as CompositebonusCfg;
  249. if (num < compositeCfg.Count ||
  250. TimeTracingDataManager.Instance.GetChapterRewardIDStatus(compositeCfg.Id, compositeCfg.Params1[0]) !=
  251. 1)
  252. {
  253. GoodsItemTipsController.ShowItemTips(compositeCfg.Bonus[0].ItemId);
  254. return;
  255. }
  256. await TimeTracingSProxy.ReqGetSuitReward(compositeCfg.Id);
  257. UpdateproBarItem();
  258. }
  259. private async void OnClickRankBtn()
  260. {
  261. await TimeTracingSProxy.ReqGetSuitFriendRank(SuitID);
  262. ViewManager.Show<TimeTracingSuitRankView>(new object[] { SuitID });
  263. }
  264. private void OnClickMakeSuitBtn()
  265. {
  266. ViewManager.Show<ClothingSyntheticView>(new object[] { SuitID, 0, _chapterID }, false, false);
  267. }
  268. private void OnClickLevelItem(EventContext context)
  269. {
  270. GObject obj = context.sender as GObject;
  271. StoryLevelCfg storyLevelCfg = (StoryLevelCfg)obj.data;
  272. MainStoryDataManager.currentLevelCfgId = storyLevelCfg.Id;
  273. InstanceZonesController.ShowLevelView(storyLevelCfg.Id,
  274. StudioDataManager.Instance.OnFinishTimeTracingLevel);
  275. }
  276. private void OnClickBtnBack()
  277. {
  278. ViewManager.GoBackFrom(typeof(TimeTracingLevelView).FullName);
  279. }
  280. private void CheckGuide(object param)
  281. {
  282. GRoot.inst.touchable = true;
  283. if (GuideDataManager.IsGuideFinish("TimeTracingShowView") <= 0)
  284. UpdateCheckGuide(null);
  285. else
  286. Timers.inst.Remove(CheckGuide);
  287. }
  288. protected void UpdateCheckGuide(object param)
  289. {
  290. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  291. GuideController.TryGuide(_ui.m_level1.target, "TimeTracingShowView", 5, "挑战。", -1, true, 0, false, false,
  292. true);
  293. GuideController.TryGuide(_ui.m_btnBack, "TimeTracingShowView", 6, "返回。", -1, true, 0, false, false, true);
  294. }
  295. }
  296. }