FieldWorkRoundResultView.cs 6.2 KB

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