StroyFightResultView.cs 9.0 KB

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