using FairyGUI; using UI.CommonGame; using System.Collections; using System.Collections.Generic; namespace GFGGame { public class GoodsItemTipsView : BaseWindow { private UI_GoodsItemTips _ui; // private ItemView itemView; private ApproachView approachView; private ItemCfg itemCfg; public override void Dispose() { base.Dispose(); // itemView.Dispose(); if (approachView != null) { approachView.Dispose(); approachView = null; } if (_ui != null) { _ui.Dispose(); _ui = null; } } protected override void OnInit() { base.OnInit(); _ui = UI_GoodsItemTips.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide); } protected override void OnShown() { base.OnShown(); int itemID = (int)(viewData as object[])[0]; object[] sourceDatas = (viewData as object[])[1] as object[]; itemCfg = ItemCfgArray.Instance.GetCfg(itemID); UpdateBase(); UpdateScore(); UpdateSourec(sourceDatas); // this.viewCom.height = _ui.m_grpTips.height; // this.viewCom.Center(); Timers.inst.AddUpdate(CheckGuide); } protected override void OnHide() { if (approachView != null) { approachView.OnHide(); } Timers.inst.Remove(CheckGuide); base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide); } private void UpdateBase() { _ui.m_comTipsBase.m_txtName.text = itemCfg.name; _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars(); _ui.m_comTipsBase.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc; _ui.m_comTipsBase.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg); RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.id, false); ET.Log.Debug(itemCfg.name + " itemId:" + itemCfg.id); } private void UpdateScore() { bool isDressUp = itemCfg.itemType == ConstItemType.DRESS_UP; _ui.m_comTipsBase.m_loaRarity.visible = isDressUp; _ui.m_comTipsBase.m_grpScore.visible = isDressUp; if (!isDressUp) return; _ui.m_comTipsBase.m_txtGong.text = "" + itemCfg.score1; _ui.m_comTipsBase.m_txtShang.text = "" + itemCfg.score2; _ui.m_comTipsBase.m_txtJue.text = "" + itemCfg.score3; _ui.m_comTipsBase.m_txtZhi.text = "" + itemCfg.score4; } private void UpdateSourec(object[] sourceDatas) { _ui.m_comTipsApproach.target.visible = sourceDatas != null; if (sourceDatas == null) return; if (approachView == null) { approachView = new ApproachView(); } approachView.OnShow(_ui.m_comTipsApproach.target, sourceDatas); } private void CheckGuide(object param) { if (_ui.m_comTipsApproach.m_list.numItems > 0 && GuideDataManager.IsGuideFinish(ConstGuideId.BUY_CLOTHING) <= 0) { UpdateToCheckGuide(null); } else { Timers.inst.Remove(CheckGuide); } } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; List _approachDatas = _ui.m_comTipsApproach.m_list.data as List; if (_approachDatas == null) return; GObject obj = null; for (int i = 0; i < _approachDatas.Count; i++) { if (_approachDatas[i][0] == ConstFunctionId.FU_ZHUANG_DIAN) { _ui.m_comTipsApproach.m_list.ScrollToView(i); UI_ListSourceItem item = UI_ListSourceItem.Proxy(_ui.m_comTipsApproach.m_list.GetChildAt(i)); obj = item.m_btnGo.target; UI_ListSourceItem.ProxyEnd(); break; } } GuideController.TryGuide(obj, ConstGuideId.BUY_CLOTHING, 4, "该物品可以在服装店购买,点开服装店看看。", -1, true, (int)(this.viewCom.y + this.viewCom.height + 10)); } } }