TimeTracingLevelInfoView.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. using FairyGUI;
  2. using UI.Main;
  3. using System.Collections.Generic;
  4. using UI.CommonGame;
  5. using UI.TimeTracing;
  6. using System;
  7. using ET;
  8. using UnityEngine;
  9. using UI_ListRewardItem = UI.Main.UI_ListRewardItem;
  10. namespace GFGGame
  11. {
  12. public class TimeTracingLevelInfoView : BaseWindow
  13. {
  14. private const int _quicklyStarCount = 2;//达到2星可快速挑战
  15. private UI_TimeTracingLevelInfoUI _ui;
  16. private int _levelID;
  17. private int _needItemId;
  18. private int _needItemCount;
  19. private int _type;
  20. private int _storyType;
  21. private int _index;
  22. private List<ItemData> _bonusList = new List<ItemData>();
  23. public override void Dispose()
  24. {
  25. if (_ui != null)
  26. {
  27. _ui.Dispose();
  28. _ui = null;
  29. }
  30. base.Dispose();
  31. }
  32. protected override void OnInit()
  33. {
  34. base.OnInit();
  35. _ui = UI_TimeTracingLevelInfoUI.Create();
  36. this.viewCom = _ui.target;
  37. this.viewCom.Center();
  38. this.modal = true;
  39. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  40. _ui.m_listBonus.itemRenderer = UpdateBonusItem;
  41. // _ui.m_listBonus.onClickItem.Add(OnClickListBonusItem);
  42. _ui.m_btnStart.onClick.Add(OnClickBtnStart);
  43. _ui.m_btnFightOnce.onClick.Add(OnClickBtnFightOnce);
  44. _ui.m_btnFightTimes.onClick.Add(OnClickBtnFightTimes);
  45. _ui.m_suitAddBtn.target.onClick.Add(OnClickSuitAddBtn);
  46. _ui.m_scoreRewardBtn.target.onClick.Add(OnClickScoreRewardBtn);
  47. _ui.m_levelRankBtn.target.onClick.Add(OnClickRankBtn);
  48. _ui.m_backBtn.onClick.Add(OnClickBackBtn);
  49. _ui.m_btnAdditionDesc.onClick.Add(OnBtnAdditionDescClick);
  50. _ui.m_addBtn.onClick.Add(OnClickAddBtn);
  51. _ui.m_ruleBtn.onClick.Add(RuleController.ShowRuleView);
  52. }
  53. protected override void AddEventListener()
  54. {
  55. base.AddEventListener();
  56. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
  57. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateVisitNum);
  58. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateBtnFightTimes);
  59. EventAgent.AddEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateRed);
  60. }
  61. protected async override void OnShown()
  62. {
  63. base.OnShown();
  64. ViewManager.SetMaskAlpha(0.8f);
  65. _levelID = (int)(viewData as object[])[0];
  66. _needItemId = (int)(viewData as object[])[1];
  67. _needItemCount = (int)(viewData as object[])[2];
  68. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  69. _type = levelCfg.type;
  70. _storyType = levelCfg.subType;
  71. _ui.m_btnStart.touchable = true;
  72. _ui.m_ruleBtn.data = 300030;
  73. await ReqGetLevelRank();
  74. RedDotController.Instance.SetComRedDot(_ui.m_scoreRewardBtn.target, TimeTracingDataManager.Instance.GetLevelRewardStatus(_levelID));
  75. UpdateView();
  76. }
  77. protected override void OnHide()
  78. {
  79. base.OnHide();
  80. ViewManager.SetMaskAlpha(0.6f);
  81. }
  82. protected override void RemoveEventListener()
  83. {
  84. base.RemoveEventListener();
  85. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateBtnFightTimes);
  86. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateVisitNum);
  87. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, UpdateBtnFightTimes);
  88. EventAgent.RemoveEventListener(ConstMessage.TIMETRACINGREDUPDATE, UpdateRed);
  89. }
  90. private void OnClickBtnStart()
  91. {
  92. // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
  93. InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
  94. if (times > 0)
  95. {
  96. DressUpFightType dressUpFightType = new DressUpFightType();
  97. dressUpFightType.levelID = _levelID;
  98. dressUpFightType.teaPartID = 0;
  99. ViewManager.Show<DressUpFightView>(dressUpFightType, true, false);
  100. this.Hide();
  101. }
  102. else
  103. {
  104. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  105. if (RoleDataManager.power < levelCfg.power)
  106. {
  107. ItemUtil.AddPower(OnClickBtnStart);
  108. }
  109. else
  110. {
  111. if (levelCfg.type == ConstInstanceZonesType.Studio && levelCfg.chapterId != StudioDataManager.Instance.GetLuckyBoxActivityID())
  112. {
  113. var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  114. ViewManager.Show<StudioBuyNumView>(studioCfg.limit);
  115. }
  116. else
  117. {
  118. PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
  119. }
  120. }
  121. }
  122. }
  123. private void OnClickBtnFightOnce()
  124. {
  125. // int time = InstanceZonesDataManager.GetCanFightTime(_levelID);
  126. int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
  127. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  128. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  129. if (starCount < fightCfg.quickFightStart)
  130. {
  131. PromptController.Instance.ShowFloatTextPrompt("挑战星数不足");
  132. return;
  133. }
  134. InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
  135. if (times > 0)
  136. {
  137. ViewManager.Show<StoryFightQuicklyView>(new object[] { 1, _needItemId, _needItemCount });
  138. this.Hide();
  139. }
  140. else
  141. {
  142. if (RoleDataManager.power < levelCfg.power)
  143. {
  144. ItemUtil.AddPower(OnClickBtnFightOnce);
  145. }
  146. else
  147. {
  148. if (levelCfg.type == ConstInstanceZonesType.Studio && levelCfg.chapterId != StudioDataManager.Instance.GetLuckyBoxActivityID())
  149. {
  150. var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId);
  151. ViewManager.Show<StudioBuyNumView>(studioCfg.limit);
  152. }
  153. else
  154. {
  155. PromptController.Instance.ShowFloatTextPrompt("挑战次数不足");
  156. }
  157. }
  158. }
  159. }
  160. private void OnClickBtnFightTimes()
  161. {
  162. //只要按钮显示说明一定可以速刷多次
  163. InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
  164. ViewManager.Show<StoryFightQuicklyView>(new object[] { times, _needItemId, _needItemCount });
  165. this.Hide();
  166. }
  167. public void UpdateRed()
  168. {
  169. RedDotController.Instance.SetComRedDot(_ui.m_scoreRewardBtn.target, TimeTracingDataManager.Instance.GetLevelRewardStatus(_levelID));
  170. }
  171. private void UpdateBonusItem(int index, GObject item)
  172. {
  173. ItemData itemData = _bonusList[index] as ItemData;
  174. UI_ListRewardItem listItem = UI_ListRewardItem.Proxy(item);
  175. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  176. listItem.m_txtName.text = cfg.name;
  177. listItem.m_txtOwner.text = string.Format("已拥有:{0}", ItemDataManager.GetItemNum(itemData.id));
  178. if (item.data == null)
  179. {
  180. item.data = new ItemView(listItem.m_comItem as GComponent);
  181. }
  182. (item.data as ItemView).SetData(itemData);
  183. //(item.data as ItemView).ShowTxtCount = false;
  184. List<ItemData> bonusOnceData = StoryBonusDataCache.GetBonusData(_levelID).bonusOnce;
  185. (item.data as ItemView).ImgShouTongVisable = !InstanceZonesDataManager.CheckLevelPass(_levelID) && index < bonusOnceData.Count;
  186. UI_ListRewardItem.ProxyEnd();
  187. }
  188. private void UpdateBtnFightTimes()
  189. {
  190. InstanceZonesDataManager.GetCanFightTime(_type, _storyType, _levelID, out int times, out string title);
  191. _ui.m_btnFightTimes.title = title;
  192. _ui.m_btnFightTimes.visible = times > 1;
  193. }
  194. private void UpdateView()
  195. {
  196. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  197. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  198. var title = levelCfg.name;
  199. switch (levelCfg.type)
  200. {
  201. case ConstInstanceZonesType.Story:
  202. title = MainStoryDataManager.CurrentChapterOrder + "-" + InstanceZonesDataManager.currentLevelOrder + " " + levelCfg.name;
  203. break;
  204. }
  205. _ui.m_txtTitle.text = title;
  206. _ui.m_txtLevelDesc.text = levelCfg.desc;
  207. ItemUtil.UpdateItemNeedNum(_ui.m_comCostCurrent, ConstItemID.POWER, levelCfg.power);
  208. _ui.m_comCostCurrent.visible = levelCfg.power > 0;
  209. _ui.m_scoreType.url = "ui://CommonGame/kp_sx_" + fightCfg.scoreType;
  210. if (fightCfg.targetName != null && fightCfg.targetName.Length > 0)
  211. {
  212. _ui.m_txtTargetName.text = "挑战对手·" + fightCfg.targetName;
  213. _ui.m_loaderHead.url = ResPathUtil.GetNpcHeadPath(fightCfg.targetRes);
  214. }
  215. else
  216. {
  217. _ui.m_txtTargetName.text = RoleDataManager.roleName;
  218. _ui.m_loaderHead.url = ResPathUtil.GetNpcHeadPath("self");
  219. }
  220. _bonusList.Clear();
  221. if (InstanceZonesDataManager.CheckLevelPass(_levelID))
  222. {
  223. _bonusList = StoryBonusDataCache.GetBonusList(_levelID, false, true);
  224. _ui.m_groupPass.visible = InstanceZonesDataManager.GetStarCountHistory(_levelID) >= _quicklyStarCount;
  225. _ui.m_groupUnpass.visible = InstanceZonesDataManager.GetStarCountHistory(_levelID) < _quicklyStarCount;
  226. UpdateBtnFightTimes();
  227. }
  228. else
  229. {
  230. _bonusList = StoryBonusDataCache.GetBonusList(_levelID, true);
  231. _ui.m_groupPass.visible = false;
  232. _ui.m_groupUnpass.visible = true;
  233. _ui.m_txtUnpassTips.SetVar("count", NumberUtil.GetChiniseNumberText(fightCfg.quickFightStart)).FlushVars();
  234. }
  235. _ui.m_listBonus.numItems = _bonusList.Count;
  236. // if (_ui.m_listBonus.numItems > 4)
  237. // {
  238. // _ui.m_listBonus.columnGap = 40;
  239. // }
  240. // else
  241. // {
  242. // _ui.m_listBonus.columnGap = 60;
  243. // }
  244. int score = InstanceZonesDataManager.GetScoreHighest(_levelID);
  245. if (score > 0)
  246. {
  247. string scoreStr = "" + score;
  248. if (score <= fightCfg.score1)
  249. {
  250. scoreStr = "[color=#A28D77]失败 " + scoreStr + "[/color]";
  251. }
  252. _ui.m_txtHighestScore.text = scoreStr;
  253. _ui.m_flower.target.visible = true;
  254. int starCount = InstanceZonesDataManager.GetStarCountHistory(_levelID);
  255. StoryUtil.UpdateStar(starCount, _ui.m_flower.target);
  256. }
  257. else
  258. {
  259. _ui.m_txtHighestScore.text = "--";
  260. _ui.m_flower.target.visible = false;
  261. }
  262. _ui.m_grpAdditionDesc.visible = false;
  263. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(TimeTracingDataManager.SuitID);
  264. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(TimeTracingDataManager.SuitID, out int count, out int totalCount);
  265. _ui.m_txtAdditionDesc.text = string.Format("{0}套装收集进度:{1}/{2}", suitCfg.name, count, totalCount);
  266. float addition = 0;
  267. StudioDataManager.Instance.filingChapterId = levelCfg.chapterId;
  268. addition = StudioDataManager.Instance.GetAddition(ConstInstanceZonesType.PureFight);
  269. addition = addition / 10000 * 100;
  270. _ui.m_txtAddition.text = string.Format("{0}%加成", addition);
  271. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(TimeTracingDataManager.SuitID);
  272. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[0]);
  273. if (itemCfg.addition == 0)
  274. {
  275. _ui.m_txtAddition.text = "无加成";
  276. }
  277. _ui.m_suitAddBtn.m_c1.selectedIndex = 0;
  278. _ui.m_scoreRewardBtn.m_c1.selectedIndex = 1;
  279. UpdateVisitNum();
  280. UpdateRankBtn();
  281. }
  282. private void UpdateRankBtn()
  283. {
  284. if (TimeTracingDataManager._LevelMaxInfoDic.ContainsKey(TimeTracingDataManager._currentChapterId)&& TimeTracingDataManager._LevelMaxInfoDic[TimeTracingDataManager._currentChapterId].ContainsKey(_levelID))
  285. {
  286. _ui.m_levelRankBtn.target.visible = true;
  287. _ui.m_levelRankBtn.m_name.text = TimeTracingDataManager._LevelMaxInfoDic[TimeTracingDataManager._currentChapterId][_levelID].RoleName;
  288. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(TimeTracingDataManager._LevelMaxInfoDic[TimeTracingDataManager._currentChapterId][_levelID].HeadItemId);
  289. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(TimeTracingDataManager._LevelMaxInfoDic[TimeTracingDataManager._currentChapterId][_levelID].HeadBorderItemId);
  290. _ui.m_levelRankBtn.m_headbg.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  291. _ui.m_levelRankBtn.m_head.url = ResPathUtil.GetHeadPath(headCfg.res);
  292. }
  293. else
  294. {
  295. _ui.m_levelRankBtn.m_name.text = "";
  296. _ui.m_levelRankBtn.m_headbg.url = "";
  297. _ui.m_levelRankBtn.m_head.url = "";
  298. }
  299. }
  300. private void RenderListTagItem(int index, GObject obj)
  301. {
  302. UI_ComTag item = UI_ComTag.Proxy(obj);
  303. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(_levelID);
  304. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  305. string tag = fightCfg.needTagsArr[index];
  306. int tagType = TagCfgArray.Instance.GetCfg(tag).type;
  307. item.m_txtTag.text = tag;
  308. item.m_loaTag.url = ResPathUtil.GetCommonGameResPath("fzd_bqbq_" + tagType);
  309. UI_ComTag.ProxyEnd();
  310. }
  311. //时光回溯活动
  312. private void UpdateVisitNum()
  313. {
  314. RoleLimitData limitData = RoleLimitDataManager.GetLimitData(ActivityFightCfgArray.Instance.GetCfg(TimeTracingDataManager._currentChapterId).limit);
  315. int time = limitData.TotalPlayMax - limitData.PlayTimes;
  316. _ui.m_limitNum.text = string.Format("今日免费次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount);
  317. }
  318. private void OnClickAddBtn()
  319. {
  320. int limitId = ActivityFightCfgArray.Instance.GetCfg(TimeTracingDataManager._currentChapterId).limit;
  321. string name = ItemCfgArray.Instance.GetCfg(LimitCfgArray.Instance.GetCfg(limitId).moneyId).name;
  322. string desc = string.Format("是否花费{0}{1}购买{2}次过关次数?", LimitCfgArray.Instance.GetCfg(limitId).moneyNumArr[0], name, 1);
  323. ViewManager.Show<ZCJBBuyTipsView>(new object[] { desc,limitId });
  324. }
  325. private void OnBtnAdditionDescClick()
  326. {
  327. _ui.m_grpAdditionDesc.visible = !_ui.m_grpAdditionDesc.visible;
  328. }
  329. private void OnClickSuitAddBtn()
  330. {
  331. ViewManager.Show<TimeTracingSuitAddView>();
  332. }
  333. private void OnClickScoreRewardBtn()
  334. {
  335. ViewManager.Show<TimeTracingLevelRewardView>(_levelID);
  336. }
  337. private async void OnClickRankBtn()
  338. {
  339. await TimeTracingSProxy.ReqGetLevelRank(_levelID);
  340. await TimeTracingSProxy.ReqGetLevelFriendRank(_levelID);
  341. ViewManager.Show<TimeTracingLevelRankView>(_levelID);
  342. }
  343. private void OnClickBackBtn()
  344. {
  345. this.Hide();
  346. }
  347. private async ETTask ReqGetLevelRank()
  348. {
  349. //await TimeTracingSProxy.ReqGetLevelRank(_levelID);
  350. //await TimeTracingSProxy.ReqGetLevelFriendRank(_levelID);
  351. }
  352. }
  353. }