StroyFightResultView.cs 6.7 KB

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