using System; using System.Collections.Generic; using FairyGUI; using UI.Main; using UnityEngine; namespace GFGGame { public class StorySkillView : BaseView { private UI_StorySkillUI _ui; private Dictionary skillScoreDic; private GameObject _gameObject0; private GameObject _gameObject1; private GoWrapper _wrapper0; private GoWrapper _wrapper1; public override void Dispose() { SceneController.DestroyObjectFromView(_gameObject0, _wrapper0); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); _ui = UI_StorySkillUI.Create(); viewCom = _ui.target; isfullScreen = true; // this.modal = false; string resPath = ResPathUtil.GetViewEffectPath("ui_fight_new", "CFKP_TX_down"); SceneController.AddObjectToView(null, null, _ui.m_comSkillShow.m_holderBottom, resPath, out _gameObject0, out _wrapper0); string resPath1 = ResPathUtil.GetViewEffectPath("ui_fight_new", "CFKP_TX_up"); SceneController.AddObjectToView(null, null, _ui.m_comSkillShow.m_holderTop, resPath1, out _gameObject1, out _wrapper1); _ui.m_comSkillShow.m_t0.ignoreEngineTimeScale = false; _ui.m_comSkillShow.m_t1.ignoreEngineTimeScale = false; _ui.m_t1.ignoreEngineTimeScale = false; } protected override void OnShown() { base.OnShown(); skillScoreDic = this.viewData as Dictionary; UpdateView(); } private void UpdateView() { if (skillScoreDic.Count > 0) { int skillId = 0; foreach (int key in skillScoreDic.Keys) { skillId = key; break; } PassivitySkillCfg skillCfg = PassivitySkillCfgArray.Instance.GetCfg(skillId); _ui.m_comSkillShow.m_txtName.text = skillCfg.name; _ui.m_comSkillShow.m_ComSkillScore.m_txtCount.SetVar("value", skillScoreDic[skillId].ToString()).FlushVars(); _ui.m_comSkillShow.m_ComSkillScore.m_txtCount1.SetVar("value", skillScoreDic[skillId].ToString()).FlushVars(); _ui.m_comSkillShow.m_ComSkillScore.m_c1.selectedIndex = skillScoreDic[skillId] >= 0 ? 0 : 1; string res = skillCfg.res; if (string.IsNullOrEmpty(skillCfg.res)) { res = ItemCfgArray.Instance.GetCfg(skillCfg.cardId).res; _ui.m_comSkillShow.m_comSkillCard.m_comCard.m_loaCard.url = ResPathUtil.GetCardPath(res); // ET.Log.Debug("技能" + skillCfg.skillId + " 未配资源"); } else { //to do... } _ui.m_comSkillShow.m_t0.timeScale = FightDataManager.Instance.fightSpeed; _ui.m_comSkillShow.m_t0.Play(() => { if (skillScoreDic[skillId] > 0) { _ui.m_comSkillShow.m_t1.timeScale = FightDataManager.Instance.fightSpeed; _ui.m_comSkillShow.m_t1.Play(() => { skillScoreDic.Remove(skillId); UpdateView(); }); } else { _ui.m_t1.timeScale = FightDataManager.Instance.fightSpeed; _ui.m_t1.Play(() => { skillScoreDic.Remove(skillId); UpdateView(); }); } }); } else { this.Hide(); } } protected override void OnHide() { base.OnHide(); EventAgent.DispatchEvent(ConstMessage.SHOW_CARD_SKILL_END); } } }