using FairyGUI; using UnityEngine; using UI.Main; using System.Collections; using System.Collections.Generic; using ET; namespace GFGGame { public class StroyFightResultView : BaseView { private UI_StoryFightResultUI _ui; private GameObject _scenePrefab; private GameObject _sceneObject; private GameObject _gameObject0; private GameObject _gameObject1; private GameObject _gameObject2; private GameObject _gameObject3; private GameObject _gameObject4; private GameObject _gameObject5; private GameObject _gameObject6; private GameObject _gameObject7; private GameObject _gameObject8; private GameObject _gameObject9; private GameObject _gameObject10; private GameObject _gameObject11; private GoWrapper _wrapper0; private GoWrapper _wrapper1; private GoWrapper _wrapper2; private GoWrapper _wrapper3; private GoWrapper _wrapper4; private GoWrapper _wrapper5; private GoWrapper _wrapper6; private GoWrapper _wrapper7; private GoWrapper _wrapper8; private GoWrapper _wrapper9; private GoWrapper _wrapper10; private GoWrapper _wrapper11; private StoryFightResultData _resultData; public override void Dispose() { SceneController.DestroyObjectFromView(_gameObject0, _wrapper0); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); SceneController.DestroyObjectFromView(_gameObject2, _wrapper2); SceneController.DestroyObjectFromView(_gameObject3, _wrapper3); SceneController.DestroyObjectFromView(_gameObject4, _wrapper4); SceneController.DestroyObjectFromView(_gameObject5, _wrapper5); SceneController.DestroyObjectFromView(_gameObject6, _wrapper6); SceneController.DestroyObjectFromView(_gameObject7, _wrapper7); if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void Init() { base.Init(); _ui = UI_StoryFightResultUI.Create(); viewCom = _ui.target; isfullScreen = true; } protected override void OnInit() { base.OnInit(); _ui.m_btnClose.enabled = false; _ui.m_btnClose.onClick.Add(OnClickBtnClose); // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("fightBg"); _scenePrefab = GFGAsset.Load(ResPathUtil.GetPrefabPath("SceneFightResult")); _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0; AddEffect(); } private void AddEffect() { string resPath0 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_lose"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult0, resPath0, out _gameObject0, out _wrapper0); string resPath1 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_qualified"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult1, resPath1, out _gameObject1, out _wrapper1); string resPath2 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_good"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult2, resPath2, out _gameObject2, out _wrapper2); string resPath3 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Perfect"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderResult3, resPath3, out _gameObject3, out _wrapper3); string resPath4 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_Text_kuang"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderScore, resPath4, out _gameObject4, out _wrapper4); string resPath5 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_STAR"); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar3, resPath5, out _gameObject7, out _wrapper7); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar2, resPath5, out _gameObject6, out _wrapper6); SceneController.AddObjectToView(null, null, _ui.m_comResult.m_holderStar1, resPath5, out _gameObject5, out _wrapper5); string resPath8 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_di"); SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderProHead, resPath8, out _gameObject8, out _wrapper8); string resPath9 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_head"); SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_holder, resPath9, out _gameObject9, out _wrapper9); string resPath10 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_jindu_tx"); SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_proExp.m_comHolder.m_holder, resPath10, out _gameObject10, out _wrapper10); string resPath11 = ResPathUtil.GetViewEffectPath("ui_fight_new", "ZDJS_player"); SceneController.AddObjectToView(null, null, _ui.m_comExpBar.m_holderHead, resPath11, out _gameObject11, out _wrapper11); } protected override void OnShown() { base.OnShown(); _resultData = (StoryFightResultData)this.viewData; InstanceZonesDataManager.usedRecommend = false; InstanceZonesDataManager.isResultFighting = true; FightData roleData = InstanceZonesDataManager.roleData; if (_sceneObject == null) { _sceneObject = GameObject.Instantiate(_scenePrefab); MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false); } MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList); _ui.m_comResult.m_c1.selectedIndex = _resultData.Star; _ui.m_comResult.m_txtScore.text = "" + _resultData.Score; RoleInfoManager.Instance.UpdateHeadWithLv1(_ui.m_comExpBar.m_comHead, RoleDataManager.headId, RoleDataManager.headBorderId, RoleDataManager.lvl); _ui.m_btnClose.enabled = false; if (!this._resultData.Result) { _ui.m_comExpBar.target.visible = false; InstanceZonesDataManager.isResultFighting = false; } else { _ui.m_comExpBar.target.visible = true; StoryLevelCfg _levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(_levelCfg.fightID); _ui.m_comExpBar.m_txtExpAdded.SetVar("value", fightCfg.exp.ToString()).FlushVars(); } if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field && this._resultData.Result && FieldDataManager.Instance.currFightLv < FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId).num) { _ui.m_comExpBar.target.visible = false; Timers.inst.Add(3, 1, OnClickBtnClose); } _ui.m_comResult.m_t0.Play(AddExp); } protected override async void OnHide() { base.OnHide(); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } InstanceZonesDataManager.isResultFighting = false; MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT)); _ui.m_comResult.m_t1.Play(); _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0; if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Field) { Timers.inst.Remove(OnClickBtnClose); // if (RoleDataManager.power < _curCfg.needPower) // { // PromptController.Instance.ShowFloatTextPrompt("体力不足"); // return; // } FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfg(FieldDataManager.Instance.chapterId); int needPower = 0; for (int i = 0; i < FieldDataManager.Instance.currFightLv + 1; i++) { needPower += fieldCfg.needPower; } if (!this._resultData.Result || FieldDataManager.Instance.currFightLv == fieldCfg.num || RoleDataManager.power < needPower) { 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 OnClickBtnClose(object param) { this.Hide(); } private void AddExp() { float exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp); float cfgExp = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).exp; _ui.m_comExpBar.m_txtCurExp.text = exp.ToString(); _ui.m_comExpBar.m_txtAllExp.text = cfgExp.ToString(); _ui.m_comExpBar.m_proExp.target.max = cfgExp; _ui.m_comExpBar.m_proExp.target.value = 0; _ui.m_comExpBar.m_proExp.target.TweenValue(exp, 0.2f).OnUpdate((GTweener t) => { _ui.m_comExpBar.m_proExp.m_comHolder.target.width = t.value.x / cfgExp * _ui.m_comExpBar.m_proExp.m_comHolder.target.initWidth; }).OnComplete(() => { if (!this._resultData.Result) ViewManager.Show(); InstanceZonesDataManager.isResultFighting = false; _ui.m_btnClose.enabled = true; }); UpdateToCheckGuide(null); } } }