123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- 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 EffectUI _effectUI0;
- private EffectUI _effectUI1;
- private EffectUI _effectUI2;
- private EffectUI _effectUI3;
- private EffectUI _effectUI4;
- private EffectUI _effectUI5;
- private EffectUI _effectUI6;
- private EffectUI _effectUI7;
- private EffectUI _effectUI8;
- private EffectUI _effectUI9;
- private EffectUI _effectUI10;
- private EffectUI _effectUI11;
- private StoryFightResultData _resultData;
- public override void Dispose()
- {
- EffectUIPool.Recycle(_effectUI0);
- _effectUI0 = null;
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- EffectUIPool.Recycle(_effectUI2);
- _effectUI2 = null;
- EffectUIPool.Recycle(_effectUI3);
- _effectUI3 = null;
- EffectUIPool.Recycle(_effectUI4);
- _effectUI4 = null;
- EffectUIPool.Recycle(_effectUI5);
- _effectUI5 = null;
- EffectUIPool.Recycle(_effectUI6);
- _effectUI6 = null;
- EffectUIPool.Recycle(_effectUI7);
- _effectUI7 = null;
- EffectUIPool.Recycle(_effectUI8);
- _effectUI8 = null;
- EffectUIPool.Recycle(_effectUI9);
- _effectUI9 = null;
- EffectUIPool.Recycle(_effectUI10);
- _effectUI10 = null;
- EffectUIPool.Recycle(_effectUI11);
- _effectUI11 = 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;
- }
- 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<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
- _ui.m_comExpBar.m_proExp.m_comHolder.target.width = 0;
- AddEffect();
- }
- private void AddEffect()
- {
- _effectUI0 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult0, "ui_fight_new", "ZDJS_lose");
- _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult1, "ui_fight_new", "ZDJS_qualified");
- _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult2, "ui_fight_new", "ZDJS_good");
- _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderResult3, "ui_fight_new", "ZDJS_Perfect");
- _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderScore, "ui_fight_new", "ZDJS_Text_kuang");
- _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar3, "ui_fight_new", "ZDJS_STAR");
- _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar2, "ui_fight_new", "ZDJS_STAR");
- _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_comResult.m_holderStar1, "ui_fight_new", "ZDJS_STAR");
- _effectUI8 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_holderProHead, "ui_fight_new", "ZDJS_jindu_di");
- _effectUI9 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_holder, "ui_fight_new", "ZDJS_jindu_head");
- _effectUI10 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_proExp.m_comHolder.m_holder, "ui_fight_new", "ZDJS_jindu_tx");
- _effectUI11 = EffectUIPool.CreateEffectUI(_ui.m_comExpBar.m_holderHead, "ui_fight_new", "ZDJS_player");
- }
- 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);
- 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<FieldView>();
- 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 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<StoryFightFailView>();
- InstanceZonesDataManager.isResultFighting = false;
- _ui.m_btnClose.enabled = true;
- });
- UpdateToCheckGuide(null);
- }
- }
- }
|