StroyFightResultView.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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 GameObject _gameObject0;
  15. private GameObject _gameObject1;
  16. private GameObject _gameObject2;
  17. private GameObject _gameObject3;
  18. private GameObject _gameObject4;
  19. private GameObject _gameObject5;
  20. private GameObject _gameObject6;
  21. private GameObject _gameObject7;
  22. private GameObject _gameObject8;
  23. private GameObject _gameObject9;
  24. private GameObject _gameObject10;
  25. private GameObject _gameObject11;
  26. private GoWrapper _wrapper0;
  27. private GoWrapper _wrapper1;
  28. private GoWrapper _wrapper2;
  29. private GoWrapper _wrapper3;
  30. private GoWrapper _wrapper4;
  31. private GoWrapper _wrapper5;
  32. private GoWrapper _wrapper6;
  33. private GoWrapper _wrapper7;
  34. private GoWrapper _wrapper8;
  35. private GoWrapper _wrapper9;
  36. private GoWrapper _wrapper10;
  37. private GoWrapper _wrapper11;
  38. private StoryFightResultData _resultData;
  39. public override void Dispose()
  40. {
  41. SceneController.DestroyObjectFromView(_gameObject0, _wrapper0);
  42. SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
  43. SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
  44. SceneController.DestroyObjectFromView(_gameObject3, _wrapper3);
  45. SceneController.DestroyObjectFromView(_gameObject4, _wrapper4);
  46. SceneController.DestroyObjectFromView(_gameObject5, _wrapper5);
  47. SceneController.DestroyObjectFromView(_gameObject6, _wrapper6);
  48. SceneController.DestroyObjectFromView(_gameObject7, _wrapper7);
  49. if (_ui != null)
  50. {
  51. _ui.Dispose();
  52. }
  53. _ui = null;
  54. base.Dispose();
  55. }
  56. protected override void Init()
  57. {
  58. base.Init();
  59. _ui = UI_StoryFightResultUI.Create();
  60. viewCom = _ui.target;
  61. isfullScreen = true;
  62. }
  63. protected override void OnInit()
  64. {
  65. base.OnInit();
  66. _ui.m_btnClose.enabled = false;
  67. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  68. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("fightBg");
  69. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
  70. AddEffect();
  71. }
  72. private void AddEffect()
  73. {
  74. string resPath0 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_lose");
  75. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult0, resPath0, out _gameObject0, out _wrapper0);
  76. string resPath1 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_qualified");
  77. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult1, resPath1, out _gameObject1, out _wrapper1);
  78. string resPath2 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_good");
  79. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult2, resPath2, out _gameObject2, out _wrapper2);
  80. string resPath3 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Perfect");
  81. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult3, resPath3, out _gameObject3, out _wrapper3);
  82. string resPath4 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Text_kuang");
  83. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderScore, resPath4, out _gameObject4, out _wrapper4);
  84. string resPath5 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_STAR");
  85. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar3, resPath5, out _gameObject7, out _wrapper7);
  86. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar2, resPath5, out _gameObject6, out _wrapper6);
  87. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar1, resPath5, out _gameObject5, out _wrapper5);
  88. string resPath8 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_di");
  89. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderProHead, resPath8, out _gameObject8, out _wrapper8);
  90. string resPath9 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_head");
  91. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_holder, resPath9, out _gameObject9, out _wrapper9);
  92. string resPath10 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_tx");
  93. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_comHolder.m_holder, resPath10, out _gameObject10, out _wrapper10);
  94. string resPath11 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_player");
  95. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderHead, resPath11, out _gameObject11, out _wrapper11);
  96. }
  97. protected override void OnShown()
  98. {
  99. base.OnShown();
  100. _resultData = (StoryFightResultData)this.viewData;
  101. InstanceZonesDataManager.usedRecommend = false;
  102. InstanceZonesDataManager.isResultFighting = true;
  103. FightData roleData = InstanceZonesDataManager.roleData;
  104. if (_sceneObject == null)
  105. {
  106. _sceneObject = GameObject.Instantiate(_scenePrefab);
  107. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
  108. }
  109. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  110. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  111. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  112. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId, RoleDataManager.lvl);
  113. if (!this._resultData.Result)
  114. {
  115. _ui.m_comExpBar.target.visible = false;
  116. InstanceZonesDataManager.isResultFighting = false;
  117. }
  118. else
  119. {
  120. _ui.m_comExpBar.target.visible = true;
  121. _ui.m_btnClose.enabled = false;
  122. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  123. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  124. _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.exp.ToString()).FlushVars();
  125. }
  126. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field && this._resultData.Result && FieldDataManager.Instance.currFightLv < FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  127. {
  128. _ui.m_comExpBar.target.visible = false;
  129. Timers.inst.Add(3, 1, OnClickBtnClose);
  130. }
  131. _ui.m_comResult.m_t0.Play(AddExp);
  132. }
  133. protected override async void OnHide()
  134. {
  135. base.OnHide();
  136. if (_sceneObject != null)
  137. {
  138. GameObject.Destroy(_sceneObject);
  139. _sceneObject = null;
  140. }
  141. InstanceZonesDataManager.isResultFighting = false;
  142. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  143. _ui.m_comResult.m_t1.Play();
  144. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  145. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  146. {
  147. Timers.inst.Remove(OnClickBtnClose);
  148. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  149. {
  150. ViewManager.Show<FieldView>();
  151. if (FieldDataManager.Instance.currFightLv <= 1) return;
  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. });
  192. _ui.m_btnClose.enabled = true;
  193. UpdateToCheckGuide(null);
  194. }
  195. }
  196. }