StroyFightResultView.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 GameObject _sceneObject;
  21. private GameObject _scenePrefab;
  22. private StoryFightResultData _resultData;
  23. public override void Dispose()
  24. {
  25. if (_scenePrefab != null)
  26. {
  27. GameObject.Destroy(_scenePrefab);
  28. _scenePrefab = null;
  29. }
  30. if (_ui != null)
  31. {
  32. _ui.Dispose();
  33. }
  34. _ui = null;
  35. base.Dispose();
  36. }
  37. protected override void Init()
  38. {
  39. base.Init();
  40. _ui = UI_StoryFightResultUI.Create();
  41. viewCom = _ui.target;
  42. isfullScreen = true;
  43. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
  44. }
  45. protected override void OnInit()
  46. {
  47. base.OnInit();
  48. _ui.m_btnClose.enabled = false;
  49. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  50. }
  51. protected override void OnShown()
  52. {
  53. base.OnShown();
  54. _resultData = (StoryFightResultData)this.viewData;
  55. // Timers.inst.AddUpdate(UpdateToCheckGuide);
  56. if (_sceneObject == null)
  57. {
  58. _sceneObject = GameObject.Instantiate(_scenePrefab);
  59. }
  60. SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
  61. _ui.m_selfScore.m_txtScore.text = "" + _resultData.Score;
  62. _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  63. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  64. _ui.m_expBar.m_pbExp.max = roleLevelCfg.exp;
  65. _ui.m_expBar.m_pbExp.value = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  66. StoryUtil.UpdateStar(_resultData.Star, _ui.m_selfScore.m_flower.target);
  67. _ui.m_selfScore.m_bg.url = "ui://Main/zd_jsjm_jszi_" + _resultData.Star;
  68. TextFormat tf = _ui.m_selfScore.m_txtScore.textFormat;
  69. UpdateToCheckGuide(null);
  70. if (!this._resultData.Result)
  71. {
  72. tf.font = "ui://Main/Font3";
  73. _ui.m_expBar.m_txtLvlAdded.text = "0";
  74. _ui.m_expBar.target.visible = false;
  75. _ui.m_btnClose.enabled = true;
  76. }
  77. else
  78. {
  79. tf.font = "ui://Main/Font2";
  80. _ui.m_expBar.target.visible = true;
  81. _ui.m_btnClose.enabled = false;
  82. //过关
  83. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  84. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  85. _ui.m_expBar.m_txtLvlAdded.text = "" + fightCfg.exp;
  86. Timers.inst.Add(0.5f, 1, this.AddExp);
  87. }
  88. _ui.m_selfScore.m_txtScore.textFormat = tf;
  89. _ui.m_t0.SetValue("posY", 33, this.viewCom.height - 235);
  90. _ui.m_t0.Play();
  91. }
  92. protected override void OnHide()
  93. {
  94. base.OnHide();
  95. Timers.inst.Remove(AddExp);
  96. if (_sceneObject != null)
  97. {
  98. GameObject.Destroy(_sceneObject);
  99. _sceneObject = null;
  100. }
  101. }
  102. private void OnClickBtnClose()
  103. {
  104. this.Hide();
  105. InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);
  106. //尝试显示奖励
  107. BonusController.TryShowBonusList(_resultData.BonusList);
  108. InstanceZonesDataManager.currentCardId = -1;
  109. }
  110. private void AddExp(object param)
  111. {
  112. _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  113. int exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  114. if (exp <= _ui.m_expBar.m_pbExp.value)
  115. {
  116. _ui.m_expBar.m_pbExp.value = 0;
  117. }
  118. _ui.m_expBar.m_pbExp.TweenValue(exp, 0.2f);
  119. _ui.m_btnClose.enabled = true;
  120. }
  121. protected override void UpdateToCheckGuide(object param)
  122. {
  123. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  124. if (!_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_FAILED, 1, "不要气馁呀,可以通过再次挑战已通关的关卡、摘星、绣坊等途径获取更多的物资来提升自己的战斗力哦!", -1, true, (int)(this.viewCom.height - 150));
  125. if (_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1, "这条连衣裙可真好看!点击空白区域继续", -1, true, (int)(this.viewCom.height - 400));
  126. if (_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1, "你太厉害了,初次对战就获得了这么好的战绩,继续加油吧", -1, true, (int)(this.viewCom.height - 400));
  127. }
  128. protected override void TryCompleteGuide()
  129. {
  130. GuideCfg cfg;
  131. cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_FAILED);
  132. GuideController.TryCompleteGuideIndex(cfg.id, 1);
  133. GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_FAILED, 1);
  134. cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_SINGLE_WIN);
  135. GuideController.TryCompleteGuideIndex(cfg.id, 1);
  136. GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1);
  137. cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_TARGET_WIN);
  138. GuideController.TryCompleteGuideIndex(cfg.id, 1);
  139. GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1);
  140. }
  141. }
  142. }