StroyFightResultView.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 _scenePrefab;
  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. }
  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. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
  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 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 = GameObject.Instantiate(_scenePrefab);
  102. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, 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. }
  128. protected override async void OnHide()
  129. {
  130. base.OnHide();
  131. if (_sceneObject != null)
  132. {
  133. GameObject.Destroy(_sceneObject);
  134. _sceneObject = null;
  135. }
  136. InstanceZonesDataManager.isResultFighting = false;
  137. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  138. _ui.m_comResult.m_t1.Play();
  139. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  140. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  141. {
  142. Timers.inst.Remove(OnClickBtnClose);
  143. FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId);
  144. int needPower = 0;
  145. for (int i = 0; i < FieldDataManager.Instance.currFightLv + 1; i++)
  146. {
  147. needPower += fieldCfg.needPower;
  148. }
  149. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == fieldCfg.num || RoleDataManager.power < needPower)
  150. {
  151. ViewManager.Show<FieldView>();
  152. bool result = await FieldSProxy.ReqFieldInstanceResult();
  153. if (result)
  154. {
  155. ViewManager.Show<FieldFightEndView>();
  156. }
  157. }
  158. else
  159. {
  160. ViewManager.Show<FieldView>();
  161. ViewManager.Show<FieldFightInfoView>();
  162. }
  163. }
  164. else
  165. {
  166. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  167. //尝试显示奖励
  168. BonusController.TryShowBonusList(_resultData.BonusList);
  169. }
  170. InstanceZonesDataManager.currentCardId = -1;
  171. }
  172. private void OnClickBtnClose(object param)
  173. {
  174. this.Hide();
  175. }
  176. private void AddExp()
  177. {
  178. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  179. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).exp;
  180. _ui.m_comExpBar.m_txtCurExp.text = exp.ToString();
  181. _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString();
  182. _ui.m_comExpBar.m_proExp.target.max = cfgExp;
  183. _ui.m_comExpBar.m_proExp.target.value = 0;
  184. _ui.m_comExpBar.m_proExp.target.TweenValue(exp, 0.2f).OnUpdate((GTweener t) =>
  185. {
  186. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = t.value.x / cfgExp * _ui.m_comExpBar.m_proExp.m_comHolder.target.initWidth;
  187. }).OnComplete(() =>
  188. {
  189. if (!this._resultData.Result) ViewManager.Show<StoryFightFailView>();
  190. InstanceZonesDataManager.isResultFighting = false;
  191. _ui.m_btnClose.enabled = true;
  192. });
  193. UpdateToCheckGuide(null);
  194. }
  195. }
  196. }