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 GameObject _gameObject; private GameObject _gameObject1; private GoWrapper _wrapper; private GoWrapper _wrapper1; private StoryLevelCfg _levelCfg; private StoryFightResultData _resultData; public override void Dispose() { SceneController.DestroyObjectFromView(_gameObject, _wrapper); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = 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); _ui.m_loaBg.url = ResPathUtil.GetFightBgImgPath("zd_jsjm_bjtu"); } protected override void OnShown() { base.OnShown(); _resultData = (StoryFightResultData)this.viewData; InstanceZonesDataManager.usedRecommend = false; InstanceZonesDataManager.isResultFighting = true; _ui.m_ComRoleResult.m_c1.selectedIndex = _resultData.Star; NTexture nTexture = new NTexture(EquipDataCache.cacher.RoleTextuex); _ui.m_ComRoleResult.m_comRole.m_imgRole.alpha = 1; _ui.m_ComRoleResult.m_comRole.m_imgRole.SetSize(UnityEngine.Screen.width, UnityEngine.Screen.height); _ui.m_ComRoleResult.m_comRole.m_imgRole.texture = nTexture; _ui.m_comResult.m_c1.selectedIndex = _resultData.Star; _ui.m_comResult.m_txtScore.text = "" + _resultData.Score; _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)); _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); if (!this._resultData.Result) { _ui.m_comExpBar.target.visible = false; _ui.m_btnClose.enabled = true; InstanceZonesDataManager.isResultFighting = false; } else { _ui.m_comExpBar.target.visible = true; _ui.m_btnClose.enabled = false; //过关 StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID); _ui.m_comExpBar.m_txtLvlAdded.text = string.Format("经验值:+{0}", fightCfg.exp); } if (_levelCfg.type == ConstInstanceZonesType.Field) { _ui.m_comExpBar.target.visible = false; Timers.inst.Add(3, 1, OnClickBtnClose); } _ui.m_t1.Play(AddExp); // _ui.m_ComRoleResult.m_comRole.m_t1.Play(() => // { // _ui.m_t1.Play(AddExp); // }); } protected override void OnHide() { base.OnHide(); InstanceZonesDataManager.isResultFighting = false; // Timers.inst.Remove(AddExp); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT)); Timers.inst.Remove(CheckGuide); _ui.m_comResult.target.height = 0; _ui.m_comExpBar.target.alpha = 0; _ui.m_t1.Stop(true, false); } private async void OnClickBtnClose(object param) { this.Hide(); if (_levelCfg.type == ConstInstanceZonesType.Field) { Timers.inst.Remove(OnClickBtnClose); if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num) { ViewManager.Show(); if (FieldDataManager.Instance.currFightLv <= 1) return; bool result = await FieldSProxy.ReqFieldInstanceResult(); if (result) { ViewManager.Show(); } } else { ViewManager.Show(); ViewManager.Show(); } } else { InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true); //尝试显示奖励 BonusController.TryShowBonusList(_resultData.BonusList); } InstanceZonesDataManager.currentCardId = -1; } private void AddExp() { int lv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl); _ui.m_comExpBar.m_txtLvl.text = string.Format("等级 {0}", GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)); float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp); float cfgExp = RoleLevelCfgArray.Instance.GetCfg(lv).exp; float initWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.initWidth; float curWidth = _ui.m_comExpBar.m_pbExp.m_bar.target.width; float width = exp / cfgExp * initWidth; if (width <= curWidth) { _ui.m_comExpBar.m_pbExp.m_bar.target.width = 0; } 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) => { _ui.m_comExpBar.m_pbExp.m_bar.target.width = t.value.x; }).OnComplete(() => { InstanceZonesDataManager.isResultFighting = false; }); ; // _ui.m_expBar.m_pbExp..TweenValue(exp, 0.2f); _ui.m_btnClose.enabled = true; UpdateToCheckGuide(null); Timers.inst.AddUpdate(CheckGuide); } private void CheckGuide(object param) { if (GuideDataManager.IsGuideFinish(ConstGuideId.FIRST_FIGHT_FAILED) <= 0 || GuideDataManager.IsGuideFinish(ConstGuideId.FIRST_FIGHT_SINGLE_WIN) <= 0 || GuideDataManager.IsGuideFinish(ConstGuideId.FIRST_FIGHT_TARGET_WIN) <= 0) { UpdateToCheckGuide(null); } else { Timers.inst.Remove(CheckGuide); } } 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 - 400)); if (_resultData.Result) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1, "你太厉害了,初次对战就获得了这么好的战绩,继续加油吧。", -1, true, (int)(this.viewCom.height - 400)); } 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); } } }