StroyFightResultView.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId, RoleDataManager.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_txtExpAdded.SetVar("value", fightCfg.exp.ToString()).FlushVars();
  67. }
  68. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  69. {
  70. _ui.m_comExpBar.target.visible = false;
  71. Timers.inst.Add(3, 1, OnClickBtnClose);
  72. }
  73. 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. }
  86. private async void OnClickBtnClose(object param)
  87. {
  88. this.Hide();
  89. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field)
  90. {
  91. Timers.inst.Remove(OnClickBtnClose);
  92. if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)
  93. {
  94. ViewManager.Show<FieldView>();
  95. if (FieldDataManager.Instance.currFightLv <= 1) return;
  96. bool result = await FieldSProxy.ReqFieldInstanceResult();
  97. if (result)
  98. {
  99. ViewManager.Show<FieldFightEndView>();
  100. }
  101. }
  102. else
  103. {
  104. ViewManager.Show<FieldView>();
  105. ViewManager.Show<FieldFightInfoView>();
  106. }
  107. }
  108. else
  109. {
  110. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  111. //尝试显示奖励
  112. BonusController.TryShowBonusList(_resultData.BonusList);
  113. }
  114. InstanceZonesDataManager.currentCardId = -1;
  115. }
  116. private void AddExp()
  117. {
  118. float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  119. float cfgExp = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).exp;
  120. _ui.m_comExpBar.m_txtCurExp.text = exp.ToString();
  121. _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString();
  122. _ui.m_comExpBar.m_proExp.max = cfgExp;
  123. _ui.m_comExpBar.m_proExp.value = 0;
  124. _ui.m_comExpBar.m_proExp.TweenValue(exp, 0.2f).OnComplete(() =>
  125. {
  126. InstanceZonesDataManager.isResultFighting = false;
  127. });
  128. _ui.m_btnClose.enabled = true;
  129. UpdateToCheckGuide(null);
  130. }
  131. }
  132. }