StroyFightResultView.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  71. AddEffect();
  72. }
  73. private void AddEffect()
  74. {
  75. string resPath0 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_lose");
  76. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult0, resPath0, out _gameObject0, out _wrapper0);
  77. string resPath1 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_qualified");
  78. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult1, resPath1, out _gameObject1, out _wrapper1);
  79. string resPath2 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_good");
  80. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult2, resPath2, out _gameObject2, out _wrapper2);
  81. string resPath3 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Perfect");
  82. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult3, resPath3, out _gameObject3, out _wrapper3);
  83. string resPath4 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Text_kuang");
  84. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderScore, resPath4, out _gameObject4, out _wrapper4);
  85. string resPath5 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_STAR");
  86. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar3, resPath5, out _gameObject7, out _wrapper7);
  87. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar2, resPath5, out _gameObject6, out _wrapper6);
  88. SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar1, resPath5, out _gameObject5, out _wrapper5);
  89. string resPath8 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_di");
  90. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderProHead, resPath8, out _gameObject8, out _wrapper8);
  91. string resPath9 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_head");
  92. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_holder, resPath9, out _gameObject9, out _wrapper9);
  93. string resPath10 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_tx");
  94. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_comHolder.m_holder, resPath10, out _gameObject10, out _wrapper10);
  95. string resPath11 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_player");
  96. SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderHead, resPath11, out _gameObject11, out _wrapper11);
  97. }
  98. protected override void OnShown()
  99. {
  100. base.OnShown();
  101. _resultData = (StoryFightResultData)this.viewData;
  102. InstanceZonesDataManager.usedRecommend = false;
  103. InstanceZonesDataManager.isResultFighting = true;
  104. FightData roleData = InstanceZonesDataManager.roleData;
  105. if (_sceneObject == null)
  106. {
  107. _sceneObject = GameObject.Instantiate(_scenePrefab);
  108. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
  109. }
  110. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  111. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  112. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  113. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId, RoleDataManager.lvl);
  114. _ui.m_btnClose.enabled = false;
  115. if (!this._resultData.Result)
  116. {
  117. _ui.m_comExpBar.target.visible = false;
  118. InstanceZonesDataManager.isResultFighting = false;
  119. }
  120. else
  121. {
  122. _ui.m_comExpBar.target.visible = true;
  123. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  124. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  125. _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.exp.ToString()).FlushVars();
  126. }
  127. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field && this._resultData.Result && FieldDataManager.Instance.currFightLv < FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  128. {
  129. _ui.m_comExpBar.target.visible = false;
  130. Timers.inst.Add(3, 1, OnClickBtnClose);
  131. }
  132. _ui.m_comResult.m_t0.Play(AddExp);
  133. }
  134. protected override async void OnHide()
  135. {
  136. base.OnHide();
  137. if (_sceneObject != null)
  138. {
  139. GameObject.Destroy(_sceneObject);
  140. _sceneObject = null;
  141. }
  142. InstanceZonesDataManager.isResultFighting = false;
  143. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  144. _ui.m_comResult.m_t1.Play();
  145. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
  146. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  147. {
  148. Timers.inst.Remove(OnClickBtnClose);
  149. // if (RoleDataManager.power < _curCfg.needPower)
  150. // {
  151. // PromptController.Instance.ShowFloatTextPrompt("体力不足");
  152. // return;
  153. // }
  154. FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId);
  155. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == fieldCfg.num || RoleDataManager.power < fieldCfg.needPower)
  156. {
  157. ViewManager.Show<FieldView>();
  158. if (FieldDataManager.Instance.currFightLv <= 1) return;
  159. bool result = await FieldSProxy.ReqFieldInstanceResult();
  160. if (result)
  161. {
  162. ViewManager.Show<FieldFightEndView>();
  163. }
  164. }
  165. else
  166. {
  167. ViewManager.Show<FieldView>();
  168. ViewManager.Show<FieldFightInfoView>();
  169. }
  170. }
  171. else
  172. {
  173. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  174. //尝试显示奖励
  175. BonusController.TryShowBonusList(_resultData.BonusList);
  176. }
  177. InstanceZonesDataManager.currentCardId = -1;
  178. }
  179. private void OnClickBtnClose(object param)
  180. {
  181. this.Hide();
  182. }
  183. private void AddExp()
  184. {
  185. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  186. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).exp;
  187. _ui.m_comExpBar.m_txtCurExp.text = exp.ToString();
  188. _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString();
  189. _ui.m_comExpBar.m_proExp.target.max = cfgExp;
  190. _ui.m_comExpBar.m_proExp.target.value = 0;
  191. _ui.m_comExpBar.m_proExp.target.TweenValue(exp, 0.2f).OnUpdate((GTweener t) =>
  192. {
  193. _ui.m_comExpBar.m_proExp.m_comHolder.target.width = t.value.x / cfgExp * _ui.m_comExpBar.m_proExp.m_comHolder.target.initWidth;
  194. }).OnComplete(() =>
  195. {
  196. if (!this._resultData.Result) ViewManager.Show<StoryFightFailView>();
  197. InstanceZonesDataManager.isResultFighting = false;
  198. _ui.m_btnClose.enabled = true;
  199. });
  200. UpdateToCheckGuide(null);
  201. }
  202. }
  203. }