using FairyGUI; using UnityEngine; using UI.Main; using System.Collections; using System.Collections.Generic; using ET; namespace GFGGame { public struct StoryFightResultData { public bool Result; public int Score; public int Star; public bool FirstPass; public List BonusList; } public class StroyFightResultView : BaseView { private UI_StoryFightResultUI _ui; private GameObject _sceneObject; private GameObject _scenePrefab; private StoryFightResultData _resultData; public override void Dispose() { if (_scenePrefab != null) { GameObject.Destroy(_scenePrefab); _scenePrefab = null; } if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void Init() { base.Init(); _ui = UI_StoryFightResultUI.Create(); viewCom = _ui.target; isfullScreen = true; _scenePrefab = GFGAsset.Load(ResPathUtil.GetPrefabPath("SceneFightResult")); } protected override void OnInit() { base.OnInit(); _ui.m_btnClose.enabled = false; _ui.m_btnClose.onClick.Add(OnClickBtnClose); } protected override void OnShown() { base.OnShown(); _resultData = (StoryFightResultData)this.viewData; // Timers.inst.AddUpdate(UpdateToCheckGuide); if (_sceneObject == null) { _sceneObject = GameObject.Instantiate(_scenePrefab); } SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject); _ui.m_selfScore.m_txtScore.text = "" + _resultData.Score; _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl); RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)); _ui.m_expBar.m_pbExp.max = roleLevelCfg.exp; _ui.m_expBar.m_pbExp.value = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp); StoryUtil.UpdateStar(_resultData.Star, _ui.m_selfScore.m_flower.target); _ui.m_selfScore.m_bg.url = "ui://Main/zd_jsjm_jszi_" + _resultData.Star; TextFormat tf = _ui.m_selfScore.m_txtScore.textFormat; UpdateToCheckGuide(null); if (!this._resultData.Result) { tf.font = "ui://Main/Font3"; _ui.m_expBar.m_txtLvlAdded.text = "0"; _ui.m_expBar.target.visible = false; _ui.m_btnClose.enabled = true; } else { tf.font = "ui://Main/Font2"; _ui.m_expBar.target.visible = true; _ui.m_btnClose.enabled = false; //过关 StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); _ui.m_expBar.m_txtLvlAdded.text = "" + fightCfg.exp; Timers.inst.Add(0.5f, 1, this.AddExp); } _ui.m_selfScore.m_txtScore.textFormat = tf; } protected override void OnHide() { base.OnHide(); Timers.inst.Remove(AddExp); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } } private void OnClickBtnClose() { this.Hide(); InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true); //尝试显示奖励 BonusController.TryShowBonusList(_resultData.BonusList); InstanceZonesDataManager.currentCardId = -1; } private void AddExp(object param) { _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl); int exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp); if (exp <= _ui.m_expBar.m_pbExp.value) { _ui.m_expBar.m_pbExp.value = 0; } _ui.m_expBar.m_pbExp.TweenValue(exp, 0.2f); _ui.m_btnClose.enabled = true; } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; if (!_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_FAILED, 1, "不要气馁呀,可以通过再次挑战已通关的关卡、摘星、绣坊等途径获取更多的物资来提升自己的战斗力哦!", -1, true, (int)(this.viewCom.height - 150)); if (_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1, "这条连衣裙可真好看!点击空白区域继续", -1, true, (int)(this.viewCom.height - 150)); if (_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1, "你太厉害了,初次对战就获得了这么好的战绩,继续加油吧", -1, true, (int)(this.viewCom.height - 350)); } protected override void TryCompleteGuide() { GuideCfg cfg; cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_FAILED); GuideController.TryCompleteGuideIndex(cfg.id, 1); GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_FAILED, 1); cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_SINGLE_WIN); GuideController.TryCompleteGuideIndex(cfg.id, 1); GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1); cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_TARGET_WIN); GuideController.TryCompleteGuideIndex(cfg.id, 1); GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1); } } }