StroyFightResultView.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. FightData roleData = InstanceZonesDataManager.roleData;
  46. if (_sceneObject == null)
  47. {
  48. _sceneObject = GameObject.Instantiate(_scenePrefab);
  49. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
  50. }
  51. MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);
  52. _ui.m_comResult.m_c1.selectedIndex = _resultData.Star;
  53. _ui.m_comResult.m_txtScore.text = "" + _resultData.Score;
  54. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  55. if (!this._resultData.Result)
  56. {
  57. _ui.m_comExpBar.target.visible = false;
  58. InstanceZonesDataManager.isResultFighting = false;
  59. }
  60. else
  61. {
  62. _ui.m_comExpBar.target.visible = true;
  63. _ui.m_btnClose.enabled = false;
  64. StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  65. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID);
  66. _ui.m_comExpBar.m_txtLvlAdded.text = string.Format("经验值:+{0}", fightCfg.exp);
  67. }
  68. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  69. {
  70. _ui.m_comExpBar.target.visible = false;
  71. Timers.inst.Add(3, 1, OnClickBtnClose);
  72. }
  73. _ui.m_t1.Play(AddExp);
  74. }
  75. protected override void OnHide()
  76. {
  77. base.OnHide();
  78. if (_sceneObject != null)
  79. {
  80. GameObject.Destroy(_sceneObject);
  81. _sceneObject = null;
  82. }
  83. InstanceZonesDataManager.isResultFighting = false;
  84. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  85. _ui.m_comResult.target.height = 0;
  86. _ui.m_comExpBar.target.alpha = 0;
  87. _ui.m_t1.Stop(true, false);
  88. }
  89. private async void OnClickBtnClose(object param)
  90. {
  91. this.Hide();
  92. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  93. {
  94. Timers.inst.Remove(OnClickBtnClose);
  95. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  96. {
  97. ViewManager.Show<FieldView>();
  98. if (FieldDataManager.Instance.currFightLv <= 1) return;
  99. bool result = await FieldSProxy.ReqFieldInstanceResult();
  100. if (result)
  101. {
  102. ViewManager.Show<FieldFightEndView>();
  103. }
  104. }
  105. else
  106. {
  107. ViewManager.Show<FieldView>();
  108. ViewManager.Show<FieldFightInfoView>();
  109. }
  110. }
  111. else
  112. {
  113. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  114. //尝试显示奖励
  115. BonusController.TryShowBonusList(_resultData.BonusList);
  116. }
  117. InstanceZonesDataManager.currentCardId = -1;
  118. }
  119. private void AddExp()
  120. {
  121. int lv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  122. _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  123. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  124. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(lv).exp;
  125. _ui.m_comExpBar.m_pbExp.m_title.text = string.Format("{0}/{1}", exp, cfgExp);
  126. float initWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.initWidth;
  127. float curWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.width;
  128. float width = exp / cfgExp * initWidth;
  129. if (width <= curWidth)
  130. {
  131. _ui.m_comExpBar.m_pbExp.m_bar.target.width = 0;
  132. }
  133. 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) =>
  134. {
  135. _ui.m_comExpBar.m_pbExp.m_bar.target.width = t.value.x;
  136. }).OnComplete(() =>
  137. {
  138. InstanceZonesDataManager.isResultFighting = false;
  139. }); ;
  140. // _ui.m_expBar.m_pbExp..TweenValue(exp, 0.2f);
  141. _ui.m_btnClose.enabled = true;
  142. UpdateToCheckGuide(null);
  143. }
  144. }
  145. }