FieldWorkRoundResultView.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System.Threading.Tasks;
  2. using cfg.GfgCfg;
  3. using ET;
  4. using FairyGUI;
  5. //using UI.Arena;
  6. using UnityEngine;
  7. using UI.FieldWork;
  8. namespace GFGGame
  9. {
  10. public class FieldWorkRoundResultView : BaseWindow
  11. {
  12. private UI_FieldWorkRoundResultUI _ui;
  13. private FieldWorkDataManager _dataManager;
  14. private int winCount = 0;
  15. private bool isFinallyFight = false;//是否最后一场战斗
  16. public override void Dispose()
  17. {
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. _ui = null;
  22. }
  23. base.Dispose();
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_FieldWorkRoundResultUI.PACKAGE_NAME;
  29. _ui = UI_FieldWorkRoundResultUI.Create();
  30. this.viewCom = _ui.target;
  31. this.viewCom.Center();
  32. this.modal = true;
  33. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  34. _ui.m_list.itemRenderer = RenderListItem;
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected async override void OnShown()
  41. {
  42. base.OnShown();
  43. ViewManager.SetMaskAlpha(0);
  44. winCount = 0;
  45. _dataManager = FieldWorkDataManager.Instance;
  46. //_ui.m_list.numItems = _dataManager.CurFightIndex;
  47. _ui.m_list.numItems = FieldWorkDataManager.Instance.myScore.Count;
  48. isFinallyFight = _ui.m_list.numItems == 3;
  49. _ui.m_ComResult.target.visible = isFinallyFight;
  50. _ui.m_loaResule.visible = isFinallyFight;
  51. this.clickBlankToClose = isFinallyFight;
  52. if (isFinallyFight)
  53. {
  54. long myAllScore = 0;
  55. long targetAllScore = FieldWorkDataManager.Instance.targetWinScore;
  56. for (int i = 0; i < FieldWorkDataManager.Instance.myScore.Count; i++)
  57. {
  58. myAllScore += FieldWorkDataManager.Instance.myScore[i];
  59. }
  60. bool isWin = myAllScore > targetAllScore;
  61. _ui.m_loaResule.url = isWin ? "ui://FieldWork/kstzjj_slsl" : "ui://FieldWork/kstzjj_shib";
  62. _ui.m_ComResult.m_comResult.m_txtMyFightScore.text = myAllScore.ToString();
  63. _ui.m_ComResult.m_comResult.m_txtTargetFightScore.text = targetAllScore.ToString();
  64. bool result = await FieldWorkSproxy.ReqFieldWorkFight(FieldWorkDataManager.Instance.currentLevelID);
  65. if (result)
  66. {
  67. if (FieldWorkDataManager.Instance.CimbingTowerLevelInfoList.ContainsKey(FieldWorkDataManager.Instance.currentLevelID))
  68. {
  69. if (FieldWorkDataManager.Instance.CimbingTowerLevelInfoList[FieldWorkDataManager.Instance.currentLevelID].IsPass)
  70. {
  71. await FieldWorkSproxy.ReqChangeFieldWorkDressup();
  72. }
  73. }
  74. else
  75. {
  76. }
  77. }
  78. else
  79. {
  80. //PromptController.Instance.ShowFloatTextPrompt("未通过!");
  81. }
  82. }
  83. else
  84. {
  85. Timers.inst.Add(1, 1, StartNextRound);
  86. }
  87. Timers.inst.AddUpdate(CheckGuide);
  88. }
  89. protected override void OnHide()
  90. {
  91. base.OnHide();
  92. ViewManager.SetMaskAlpha(0.6f);
  93. if (isFinallyFight)
  94. {
  95. MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  96. FinishFight();
  97. }
  98. }
  99. protected override void RemoveEventListener()
  100. {
  101. base.RemoveEventListener();
  102. }
  103. private void RenderListItem(int index, GObject obj)
  104. {
  105. UI_ListResultItem item = UI_ListResultItem.Proxy(obj);
  106. item.m_txtRound.text = "回合 " + (index + 1).ToString();
  107. RoleInfoManager.Instance.UpdateHead(item.m_comMyHead, RoleDataManager.headId, RoleDataManager.headBorderId);
  108. int myCardId = FieldWorkDataManager.Instance.DressupList[index].cardId;
  109. ItemCfg cardCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(myCardId);
  110. item.m_loaMyCard.m_comCardmask.m_loaCard.url = cardCfg == null ? "" : ResPathUtil.GetCardIconPath(cardCfg.Res);
  111. int scoreType = FieldWorkDataManager.Instance.ThemeList[index];
  112. item.m_loaScore.url = ResPathUtil.GetScorePath(scoreType);
  113. long myScore = FieldWorkDataManager.Instance.myScore[index];
  114. item.m_txtMyScore.text = myScore.ToString();
  115. UI_ListResultItem.ProxyEnd();
  116. }
  117. private void StartNextRound(object param)
  118. {
  119. ViewManager.Hide<FieldWorkFightResultView>();
  120. ViewManager.Show<StoryFightSingleScoreView>(_dataManager.DressupList[_dataManager.CurFightIndex]);
  121. ViewManager.Show<FieldWorkRoundTipsView>();
  122. this.Hide();
  123. }
  124. private void FinishFight()
  125. {
  126. FieldWorkDataManager dataManager = FieldWorkDataManager.Instance;
  127. ViewManager.Hide<FieldWorkFightResultView>();
  128. if(dataManager.BonusList != null || dataManager.BonusList.Count >0)
  129. {
  130. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(dataManager.BonusList), () =>
  131. {
  132. // ViewManager.Hide<ArenaFightResultView>();
  133. });
  134. dataManager.BonusList.Clear();
  135. }
  136. }
  137. private void CheckGuide(object param)
  138. {
  139. if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0 && isFinallyFight)
  140. {
  141. UpdateCheckGuide(null);
  142. }
  143. else
  144. {
  145. Timers.inst.Remove(CheckGuide);
  146. }
  147. }
  148. protected void UpdateCheckGuide(object param)
  149. {
  150. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  151. GuideController.TryGuide(_ui.m_guide.target, ConstGuideId.FIELD, 15, "三轮累计的分数将决定关卡的通关与否!");
  152. }
  153. }
  154. }