StroyFightResultView.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 StoryFightResultData _resultData;
  15. public override void Dispose()
  16. {
  17. if (_ui != null)
  18. {
  19. _ui.Dispose();
  20. }
  21. _ui = null;
  22. base.Dispose();
  23. }
  24. protected override void Init()
  25. {
  26. base.Init();
  27. _ui = UI_StoryFightResultUI.Create();
  28. viewCom = _ui.target;
  29. isfullScreen = true;
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. _ui.m_btnClose.enabled = false;
  35. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  36. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("fightBg");
  37. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
  38. }
  39. protected override void OnShown()
  40. {
  41. base.OnShown();
  42. _resultData = (StoryFightResultData)this.viewData;
  43. InstanceZonesDataManager.usedRecommend = false;
  44. InstanceZonesDataManager.isResultFighting = true;
  45. NTexture nTexture = new NTexture(FightDataManager.Instance.RoleTextuex);
  46. _ui.m_comRoleResult.m_c1.selectedIndex = _resultData.Star;
  47. _ui.m_comRoleResult.m_comRole.m_imgRole.SetSize(GRoot.inst.width, GRoot.inst.height);
  48. _ui.m_comRoleResult.m_comRole.m_imgRole.texture = nTexture;
  49. _ui.m_comRoleResult.m_comRole.m_imgRole.alpha = 1;
  50. // FightData roleData = InstanceZonesDataManager.roleData;
  51. // if (_sceneObject == null)
  52. // {
  53. // _sceneObject = GameObject.Instantiate(_scenePrefab);
  54. // MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
  55. // }
  56. // MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  57. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  58. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  59. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  60. if (!this._resultData.Result)
  61. {
  62. _ui.m_comExpBar.target.visible = false;
  63. InstanceZonesDataManager.isResultFighting = false;
  64. }
  65. else
  66. {
  67. _ui.m_comExpBar.target.visible = true;
  68. _ui.m_btnClose.enabled = false;
  69. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  70. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  71. _ui.m_comExpBar.m_txtLvlAdded.text = string.Format("经验值:+{0}", fightCfg.exp);
  72. }
  73. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  74. {
  75. _ui.m_comExpBar.target.visible = false;
  76. Timers.inst.Add(3, 1, OnClickBtnClose);
  77. }
  78. GetCurStar(out Transition transition);
  79. _ui.m_t0.Play();//播放重置动画
  80. _ui.m_comRoleResult.m_t0.Play();//播放重置动画
  81. _ui.m_comRoleResult.m_comRole.m_t0.Play(() =>
  82. {
  83. transition.Play(() =>
  84. {
  85. _ui.m_t1.Play(AddExp);
  86. });
  87. });
  88. }
  89. private void GetCurStar(out Transition transition)
  90. {
  91. transition = _ui.m_comRoleResult.m_t0;
  92. if (_resultData.Star == 1)
  93. {
  94. transition = _ui.m_comRoleResult.m_t1;
  95. }
  96. else if (_resultData.Star == 2)
  97. {
  98. transition = _ui.m_comRoleResult.m_t2;
  99. }
  100. else if (_resultData.Star == 3)
  101. {
  102. transition = _ui.m_comRoleResult.m_t3;
  103. }
  104. }
  105. protected override void OnHide()
  106. {
  107. base.OnHide();
  108. if (_sceneObject != null)
  109. {
  110. GameObject.Destroy(_sceneObject);
  111. _sceneObject = null;
  112. }
  113. InstanceZonesDataManager.isResultFighting = false;
  114. // Timers.inst.Remove(AddExp);
  115. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  116. _ui.m_comResult.target.height = 0;
  117. _ui.m_comExpBar.target.alpha = 0;
  118. _ui.m_t1.Stop(true, false);
  119. }
  120. private async void OnClickBtnClose(object param)
  121. {
  122. this.Hide();
  123. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  124. {
  125. Timers.inst.Remove(OnClickBtnClose);
  126. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  127. {
  128. ViewManager.Show<FieldView>();
  129. if (FieldDataManager.Instance.currFightLv <= 1) return;
  130. bool result = await FieldSProxy.ReqFieldInstanceResult();
  131. if (result)
  132. {
  133. ViewManager.Show<FieldFightEndView>();
  134. }
  135. }
  136. else
  137. {
  138. ViewManager.Show<FieldView>();
  139. ViewManager.Show<FieldFightInfoView>();
  140. }
  141. }
  142. else
  143. {
  144. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  145. //尝试显示奖励
  146. BonusController.TryShowBonusList(_resultData.BonusList);
  147. }
  148. InstanceZonesDataManager.currentCardId = -1;
  149. }
  150. private void AddExp()
  151. {
  152. int lv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  153. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  154. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  155. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(lv).exp;
  156. _ui.m_comExpBar.m_pbExp.m_title.text = string.Format("{0}/{1}", exp, cfgExp);
  157. float initWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.initWidth;
  158. float curWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.width;
  159. float width = exp / cfgExp * initWidth;
  160. if (width <= curWidth)
  161. {
  162. _ui.m_comExpBar.m_pbExp.m_bar.target.width = 0;
  163. }
  164. GTween.To(_ui.m_comExpBar.m_pbExp.m_bar.target.width, width, 0.2f).SetTarget(_ui.m_comExpBar.m_pbExp.m_bar).OnUpdate((GTweener t) =>
  165. {
  166. _ui.m_comExpBar.m_pbExp.m_bar.target.width = t.value.x;
  167. }).OnComplete(() =>
  168. {
  169. InstanceZonesDataManager.isResultFighting = false;
  170. }); ;
  171. // _ui.m_expBar.m_pbExp..TweenValue(exp, 0.2f);
  172. _ui.m_btnClose.enabled = true;
  173. UpdateToCheckGuide(null);
  174. }
  175. }
  176. }