| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 | 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<ItemData> 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 StoryLevelCfg _levelCfg;        private StoryFightResultData _resultData;        public override void Dispose()        {            SceneController.DestroyObjectFromView(_gameObject);            SceneController.DestroyObjectFromView(_gameObject1);            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<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));        }        protected override void OnInit()        {            base.OnInit();            _ui.m_btnClose.enabled = false;            _ui.m_btnClose.onClick.Add(OnClickBtnClose);            string resPath = ResPathUtil.GetViewEffectPath("ui_zhandou", "ui_zd_zdjs_jdt");            SceneController.AddObjectToView(_gameObject1, null, _ui.m_expBar.m_pbExp.m_holder, resPath, out _gameObject1, out GoWrapper wrapper);        }        protected override void OnShown()        {            base.OnShown();            _resultData = (StoryFightResultData)this.viewData;            if (_sceneObject == null)            {                _sceneObject = GameObject.Instantiate(_scenePrefab);            }            InstanceZonesDataManager.usedRecommend = false;            SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);            _ui.m_txtScore.text = "" + _resultData.Score;            _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);            StoryUtil.UpdateStar(_resultData.Star, _ui.m_flower.target);            string resPath = ResPathUtil.GetViewEffectPath("ui_zhandou", string.Format("zd_zdjs_{0}", _resultData.Star));            SceneController.AddObjectToView(_gameObject, _wrapper, _ui.m_holder, resPath, out _gameObject, out _wrapper, 120);            _ui.m_holder.visible = true;            _gameObject.SetActive(true);            TextFormat tf = _ui.m_txtScore.textFormat;            UpdateToCheckGuide(null);            _ui.m_c1.selectedIndex = 0;            _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);            if (_levelCfg.type == ConstInstanceZonesType.Field)            {                _ui.m_c1.selectedIndex = 1;                Timers.inst.Add(3, 1, OnClickBtnClose);            }            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;                //过关                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_txtScore.textFormat = tf;            _ui.m_t0.SetValue("posY", 33, this.viewCom.height - 235);            _ui.m_t0.Play();        }        protected override void OnHide()        {            base.OnHide();            Timers.inst.Remove(AddExp);            if (_sceneObject != null)            {                GameObject.Destroy(_sceneObject);                _sceneObject = null;            }            MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));        }        private async void OnClickBtnClose(object param)        {            this.Hide();            if (_levelCfg.type == ConstInstanceZonesType.Field)            {                _ui.m_c1.selectedIndex = 1;                Timers.inst.Remove(OnClickBtnClose);                if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num)                {                    ViewManager.Show<FieldView>();                    if (FieldDataManager.Instance.currFightLv <= 1) return;                    bool result = await FieldSProxy.ReqFieldInstanceResult();                    if (result)                    {                        ViewManager.Show<FieldFightEndView>();                    }                }                else                {                    ViewManager.Show<FieldView>();                    ViewManager.Show<FieldFightInfoView>();                }            }            else            {                InstanceZonesController.OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, _resultData.FirstPass, true);                //尝试显示奖励                BonusController.TryShowBonusList(_resultData.BonusList);            }            InstanceZonesDataManager.currentCardId = -1;        }        private void AddExp(object param)        {            int lv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);            _ui.m_expBar.m_txtLvl.text = lv.ToString();            float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);            float cfgExp = RoleLevelCfgArray.Instance.GetCfg(lv).exp;            float initWidth = _ui.m_expBar.m_pbExp.m_bar.target.initWidth;            float curWidth = _ui.m_expBar.m_pbExp.m_bar.target.width;            float width = exp / cfgExp * initWidth;            if (width <= curWidth)            {                _ui.m_expBar.m_pbExp.m_bar.target.width = 0;            }            GTween.To(_ui.m_expBar.m_pbExp.m_bar.target.width, width, 0.2f).SetTarget(_ui.m_expBar.m_pbExp.m_bar).OnUpdate((GTweener t) =>                {                    _ui.m_expBar.m_pbExp.m_bar.target.width = t.value.x;                }); ;            // _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 - 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);        }    }}
 |