StroyFightResultView.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 =
  89. EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_holder, "ui_fight_new", "ZDJS_jindu_head");
  90. _effectUI10 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_comHolder.m_holder, "ui_fight_new",
  91. "ZDJS_jindu_tx");
  92. _effectUI11 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_holderHead, "ui_fight_new", "ZDJS_player");
  93. }
  94. protected async override void OnShown()
  95. {
  96. base.OnShown();
  97. _resultData = (StoryFightResultData)this.viewData;
  98. InstanceZonesDataManager.usedRecommend = false;
  99. InstanceZonesDataManager.isResultFighting = true;
  100. FightData roleData = InstanceZonesDataManager.roleData;
  101. if (_sceneObject == null)
  102. {
  103. PrefabManager.Instance.InstantiateAsync(ResPathUtil.GetPrefabPath("SceneFightResult"), (gameObj) =>
  104. {
  105. _sceneObject = gameObj;
  106. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, true);
  107. MyDressUpHelper.dressUpObj.AddOrRemove(180014, false);
  108. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  109. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  110. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  111. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId,
  112. RoleDataManager.headBorderId, RoleDataManager.lvl);
  113. _ui.m_btnClose.enabled = false;
  114. if (!this._resultData.Result)
  115. {
  116. _ui.m_comExpBar.target.visible = false;
  117. InstanceZonesDataManager.isResultFighting = false;
  118. }
  119. else
  120. {
  121. _ui.m_comExpBar.target.visible = true;
  122. StoryLevelCfg _levelCfg =
  123. CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(InstanceZonesDataManager
  124. .currentLevelCfgId);
  125. StoryFightCfg fightCfg =
  126. CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(_levelCfg.FightID));
  127. _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.Exp.ToString()).FlushVars();
  128. }
  129. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field &&
  130. this._resultData.Result && FieldDataManager.Instance.currFightLv < CommonDataManager.Tables
  131. .TblFieldCfg.GetOrDefault(FieldDataManager.Instance.chapterId).Num)
  132. {
  133. _ui.m_comExpBar.target.visible = false;
  134. Timers.inst.Add(3, 1, OnClickBtnClose);
  135. }
  136. _ui.m_comResult.m_t0.Play(AddExp);
  137. });
  138. return;
  139. }
  140. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  141. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  142. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  143. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId,
  144. RoleDataManager.headBorderId, RoleDataManager.lvl);
  145. _ui.m_btnClose.enabled = false;
  146. if (!this._resultData.Result)
  147. {
  148. _ui.m_comExpBar.target.visible = false;
  149. InstanceZonesDataManager.isResultFighting = false;
  150. }
  151. else
  152. {
  153. _ui.m_comExpBar.target.visible = true;
  154. StoryLevelCfg _levelCfg =
  155. CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(InstanceZonesDataManager.currentLevelCfgId);
  156. StoryFightCfg fightCfg =
  157. CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(_levelCfg.FightID));
  158. _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.Exp.ToString()).FlushVars();
  159. }
  160. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field && this._resultData.Result &&
  161. FieldDataManager.Instance.currFightLv < CommonDataManager.Tables.TblFieldCfg
  162. .GetOrDefault(FieldDataManager.Instance.chapterId).Num)
  163. {
  164. _ui.m_comExpBar.target.visible = false;
  165. Timers.inst.Add(3, 1, OnClickBtnClose);
  166. }
  167. _ui.m_comResult.m_t0.Play(AddExp);
  168. StoryLevelCfg storylevel =
  169. CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(InstanceZonesDataManager.currentLevelCfgId);
  170. if (_resultData.Result && storylevel.Type == 6 && storylevel.SubType == 2)
  171. {
  172. await TimeTracingSProxy.ReqGetMaxLevelInfo(TimeTracingDataManager._currentChapterId);
  173. await TimeTracingSProxy.ReqGetAppointLevelRewardStatus(InstanceZonesDataManager.currentLevelCfgId);
  174. await TimeTracingSProxy.ReqGetSuitRewardStatus();
  175. }
  176. }
  177. protected override void OnHide()
  178. {
  179. base.OnHide();
  180. if (_sceneObject != null)
  181. {
  182. PrefabManager.Instance.Restore(_sceneObject);
  183. _sceneObject = null;
  184. }
  185. MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  186. _ui.m_comResult.m_t1.Play();
  187. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  188. InstanceZonesDataManager.isResultFighting = false;
  189. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  190. {
  191. InstanceZonesDataManager.isFightResultHide = true;
  192. InstanceZonesDataManager.resultData = this._resultData;
  193. //ViewManager.DeleteViewStackCountDown(1);
  194. //ViewManager.Show<FieldView>();
  195. Timers.inst.Remove(OnClickBtnClose);
  196. }
  197. else
  198. {
  199. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId,
  200. _resultData.FirstPass, true);
  201. //尝试显示奖励
  202. BonusController.TryShowBonusList(_resultData.BonusList);
  203. }
  204. InstanceZonesDataManager.currentCardId = -1;
  205. }
  206. private void OnClickBtnClose(object param)
  207. {
  208. this.Hide();
  209. }
  210. private void AddExp()
  211. {
  212. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  213. float cfgExp = CommonDataManager.Tables.TblRoleLevelCfg.GetOrDefault(RoleDataManager.lvl).Exp;
  214. _ui.m_comExpBar.m_txtCurExp.text = exp.ToString();
  215. _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString();
  216. _ui.m_comExpBar.m_proExp.target.max = cfgExp;
  217. _ui.m_comExpBar.m_proExp.target.value = 0;
  218. _ui.m_comExpBar.m_proExp.target.TweenValue(exp, 0.2f).OnUpdate((GTweener t) =>
  219. {
  220. _ui.m_comExpBar.m_proExp.m_comHolder.target.width =
  221. t.value.x / cfgExp * _ui.m_comExpBar.m_proExp.m_comHolder.target.initWidth;
  222. }).OnComplete(() =>
  223. {
  224. if (!this._resultData.Result) ViewManager.Show<StoryFightFailView>();
  225. InstanceZonesDataManager.isResultFighting = false;
  226. _ui.m_btnClose.enabled = true;
  227. });
  228. UpdateToCheckGuide(null);
  229. }
  230. }
  231. }