StroyFightResultView.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.Main;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class StroyFightResultView : BaseView
  10. {
  11. private UI_StoryFightResultUI _ui;
  12. private GameObject _sceneObject;
  13. private EffectUI _effectUI0;
  14. private EffectUI _effectUI1;
  15. private EffectUI _effectUI2;
  16. private EffectUI _effectUI3;
  17. private EffectUI _effectUI4;
  18. private EffectUI _effectUI5;
  19. private EffectUI _effectUI6;
  20. private EffectUI _effectUI7;
  21. private EffectUI _effectUI8;
  22. private EffectUI _effectUI9;
  23. private EffectUI _effectUI10;
  24. private EffectUI _effectUI11;
  25. private StoryFightResultData _resultData;
  26. public override void Dispose()
  27. {
  28. EffectUIPool.Recycle(_effectUI0);
  29. _effectUI0 = null;
  30. EffectUIPool.Recycle(_effectUI1);
  31. _effectUI1 = null;
  32. EffectUIPool.Recycle(_effectUI2);
  33. _effectUI2 = null;
  34. EffectUIPool.Recycle(_effectUI3);
  35. _effectUI3 = null;
  36. EffectUIPool.Recycle(_effectUI4);
  37. _effectUI4 = null;
  38. EffectUIPool.Recycle(_effectUI5);
  39. _effectUI5 = null;
  40. EffectUIPool.Recycle(_effectUI6);
  41. _effectUI6 = null;
  42. EffectUIPool.Recycle(_effectUI7);
  43. _effectUI7 = null;
  44. EffectUIPool.Recycle(_effectUI8);
  45. _effectUI8 = null;
  46. EffectUIPool.Recycle(_effectUI9);
  47. _effectUI9 = null;
  48. EffectUIPool.Recycle(_effectUI10);
  49. _effectUI10 = null;
  50. EffectUIPool.Recycle(_effectUI11);
  51. _effectUI11 = null;
  52. if (_ui != null)
  53. {
  54. _ui.Dispose();
  55. }
  56. _ui = null;
  57. base.Dispose();
  58. }
  59. protected override void Init()
  60. {
  61. base.Init();
  62. _ui = UI_StoryFightResultUI.Create();
  63. viewCom = _ui.target;
  64. isfullScreen = true;
  65. //isReturnView = true;
  66. }
  67. protected override void OnInit()
  68. {
  69. base.OnInit();
  70. _ui.m_btnClose.enabled = false;
  71. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  72. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("fightBg");
  73. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  74. AddEffect();
  75. }
  76. private void AddEffect()
  77. {
  78. _effectUI0 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult0, "ui_fight_new", "ZDJS_lose");
  79. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult1, "ui_fight_new", "ZDJS_qualified");
  80. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult2, "ui_fight_new", "ZDJS_good");
  81. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult3, "ui_fight_new", "ZDJS_Perfect");
  82. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderScore, "ui_fight_new", "ZDJS_Text_kuang");
  83. _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar3, "ui_fight_new", "ZDJS_STAR");
  84. _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar2, "ui_fight_new", "ZDJS_STAR");
  85. _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar1, "ui_fight_new", "ZDJS_STAR");
  86. _effectUI8 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_holderProHead, "ui_fight_new", "ZDJS_jindu_di");
  87. _effectUI9 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_holder, "ui_fight_new", "ZDJS_jindu_head");
  88. _effectUI10 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_comHolder.m_holder, "ui_fight_new", "ZDJS_jindu_tx");
  89. _effectUI11 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_holderHead, "ui_fight_new", "ZDJS_player");
  90. }
  91. protected async override void OnShown()
  92. {
  93. base.OnShown();
  94. _resultData = (StoryFightResultData)this.viewData;
  95. InstanceZonesDataManager.usedRecommend = false;
  96. InstanceZonesDataManager.isResultFighting = true;
  97. FightData roleData = InstanceZonesDataManager.roleData;
  98. if (_sceneObject == null)
  99. {
  100. _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightResult"));
  101. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, true);
  102. MyDressUpHelper.dressUpObj.AddOrRemove(180014, false);
  103. }
  104. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  105. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  106. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  107. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId, RoleDataManager.lvl);
  108. _ui.m_btnClose.enabled = false;
  109. if (!this._resultData.Result)
  110. {
  111. _ui.m_comExpBar.target.visible = false;
  112. InstanceZonesDataManager.isResultFighting = false;
  113. }
  114. else
  115. {
  116. _ui.m_comExpBar.target.visible = true;
  117. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  118. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  119. _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.exp.ToString()).FlushVars();
  120. }
  121. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field && this._resultData.Result && FieldDataManager.Instance.currFightLv < FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  122. {
  123. _ui.m_comExpBar.target.visible = false;
  124. Timers.inst.Add(3, 1, OnClickBtnClose);
  125. }
  126. _ui.m_comResult.m_t0.Play(AddExp);
  127. StoryLevelCfg storylevel = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  128. if (_resultData.Result && storylevel.type == 6 && storylevel.subType == 2)
  129. {
  130. await TimeTracingSProxy.ReqGetMaxLevelInfo(TimeTracingDataManager._currentChapterId);
  131. await TimeTracingSProxy.ReqGetAppointLevelRewardStatus(InstanceZonesDataManager.currentLevelCfgId);
  132. await TimeTracingSProxy.ReqGetSuitRewardStatus();
  133. }
  134. }
  135. protected override void OnHide()
  136. {
  137. base.OnHide();
  138. if (_sceneObject != null)
  139. {
  140. PrefabManager.Instance.Restore(_sceneObject);
  141. _sceneObject = null;
  142. }
  143. MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  144. _ui.m_comResult.m_t1.Play();
  145. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  146. InstanceZonesDataManager.isResultFighting = false;
  147. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  148. {
  149. InstanceZonesDataManager.isFightResultHide = true;
  150. InstanceZonesDataManager.resultData = this._resultData;
  151. //ViewManager.DeleteViewStackCountDown(1);
  152. //ViewManager.Show<FieldView>();
  153. Timers.inst.Remove(OnClickBtnClose);
  154. }
  155. else
  156. {
  157. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  158. //尝试显示奖励
  159. BonusController.TryShowBonusList(_resultData.BonusList);
  160. }
  161. InstanceZonesDataManager.currentCardId = -1;
  162. }
  163. private void OnClickBtnClose(object param)
  164. {
  165. this.Hide();
  166. }
  167. private void AddExp()
  168. {
  169. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  170. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).exp;
  171. _ui.m_comExpBar.m_txtCurExp.text = exp.ToString();
  172. _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString();
  173. _ui.m_comExpBar.m_proExp.target.max = cfgExp;
  174. _ui.m_comExpBar.m_proExp.target.value = 0;
  175. _ui.m_comExpBar.m_proExp.target.TweenValue(exp, 0.2f).OnUpdate((GTweener t) =>
  176. {
  177. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = t.value.x / cfgExp * _ui.m_comExpBar.m_proExp.m_comHolder.target.initWidth;
  178. }).OnComplete(() =>
  179. {
  180. if (!this._resultData.Result) ViewManager.Show<StoryFightFailView>();
  181. InstanceZonesDataManager.isResultFighting = false;
  182. _ui.m_btnClose.enabled = true;
  183. });
  184. UpdateToCheckGuide(null);
  185. }
  186. }
  187. }