StroyFightResultView.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 struct StoryFightResultData
  10. {
  11. public bool Result;
  12. public int Score;
  13. public int Star;
  14. public bool FirstPass;
  15. public List<ItemData> BonusList;
  16. }
  17. public class StroyFightResultView : BaseView
  18. {
  19. private UI_StoryFightResultUI _ui;
  20. // private StoryLevelCfg _levelCfg;
  21. private StoryFightResultData _resultData;
  22. public override void Dispose()
  23. {
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. }
  28. _ui = null;
  29. base.Dispose();
  30. }
  31. protected override void Init()
  32. {
  33. base.Init();
  34. _ui = UI_StoryFightResultUI.Create();
  35. viewCom = _ui.target;
  36. isfullScreen = true;
  37. }
  38. protected override void OnInit()
  39. {
  40. base.OnInit();
  41. _ui.m_btnClose.enabled = false;
  42. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  43. _ui.m_loaBg.url = ResPathUtil.GetFightBgImgPath("fightBg");
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. _resultData = (StoryFightResultData)this.viewData;
  49. InstanceZonesDataManager.usedRecommend = false;
  50. InstanceZonesDataManager.isResultFighting = true;
  51. NTexture nTexture = new NTexture(FightDataManager.Instance.RoleTextuex);
  52. _ui.m_comRoleResult.m_c1.selectedIndex = _resultData.Star;
  53. _ui.m_comRoleResult.m_comRole.m_imgRole.SetSize(GRoot.inst.width, GRoot.inst.height);
  54. _ui.m_comRoleResult.m_comRole.m_imgRole.texture = nTexture;
  55. _ui.m_comRoleResult.m_comRole.m_imgRole.alpha = 1;
  56. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  57. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  58. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  59. if (!this._resultData.Result)
  60. {
  61. _ui.m_comExpBar.target.visible = false;
  62. InstanceZonesDataManager.isResultFighting = false;
  63. }
  64. else
  65. {
  66. _ui.m_comExpBar.target.visible = true;
  67. _ui.m_btnClose.enabled = false;
  68. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Arena)
  69. {
  70. }
  71. else
  72. {
  73. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  74. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  75. _ui.m_comExpBar.m_txtLvlAdded.text = string.Format("经验值:+{0}", fightCfg.exp);
  76. }
  77. }
  78. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  79. {
  80. _ui.m_comExpBar.target.visible = false;
  81. Timers.inst.Add(3, 1, OnClickBtnClose);
  82. }
  83. GetCurStar(out Transition transition);
  84. _ui.m_t0.Play();//播放重置动画
  85. _ui.m_comRoleResult.m_t0.Play();//播放重置动画
  86. _ui.m_comRoleResult.m_comRole.m_t0.Play(() =>
  87. {
  88. transition.Play(() =>
  89. {
  90. _ui.m_t1.Play(AddExp);
  91. });
  92. });
  93. }
  94. private void GetCurStar(out Transition transition)
  95. {
  96. transition = _ui.m_comRoleResult.m_t0;
  97. if (_resultData.Star == 1)
  98. {
  99. transition = _ui.m_comRoleResult.m_t1;
  100. }
  101. else if (_resultData.Star == 2)
  102. {
  103. transition = _ui.m_comRoleResult.m_t2;
  104. }
  105. else if (_resultData.Star == 3)
  106. {
  107. transition = _ui.m_comRoleResult.m_t3;
  108. }
  109. }
  110. protected override void OnHide()
  111. {
  112. base.OnHide();
  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 if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Arena)
  143. {
  144. if (ArenaDataManager.Instance.CurFightIndex < ArenaDataManager.Instance.ThemeList.Count)
  145. {
  146. ArenaDataManager.Instance.CurFightIndex++;
  147. }
  148. else
  149. {
  150. }
  151. }
  152. else
  153. {
  154. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  155. //尝试显示奖励
  156. BonusController.TryShowBonusList(_resultData.BonusList);
  157. }
  158. InstanceZonesDataManager.currentCardId = -1;
  159. }
  160. private void AddExp()
  161. {
  162. int lv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  163. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  164. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  165. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(lv).exp;
  166. _ui.m_comExpBar.m_pbExp.m_title.text = string.Format("{0}/{1}", exp, cfgExp);
  167. float initWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.initWidth;
  168. float curWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.width;
  169. float width = exp / cfgExp * initWidth;
  170. if (width <= curWidth)
  171. {
  172. _ui.m_comExpBar.m_pbExp.m_bar.target.width = 0;
  173. }
  174. 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) =>
  175. {
  176. _ui.m_comExpBar.m_pbExp.m_bar.target.width = t.value.x;
  177. }).OnComplete(() =>
  178. {
  179. InstanceZonesDataManager.isResultFighting = false;
  180. }); ;
  181. // _ui.m_expBar.m_pbExp..TweenValue(exp, 0.2f);
  182. _ui.m_btnClose.enabled = true;
  183. UpdateToCheckGuide(null);
  184. }
  185. }
  186. }