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; approachView = new ApproachView(); approachView.OnInit(_ui.m_comTipsApproach.target); _ui.m_comTipsBase.m_listTag.itemRenderer = RenderListTagItem; _ui.m_comTipsBase.m_listItem.itemRenderer = ListItemRenderer; _ui.m_comBg.m_btnClose.onClick.Add(Hide); } 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(); UpdateTags(); UpdateItems(); 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() { if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL) { _ui.m_comBg.m_txtTitle.text = string.Format("{0} _{1}", itemCfg.name, itemCfg.id); } else { _ui.m_comBg.m_txtTitle.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); _ui.m_comTipsBase.m_txtType.visible = itemCfg.itemType == ConstItemType.DRESS_UP; if (itemCfg.itemType == ConstItemType.DRESS_UP) { _ui.m_comTipsBase.m_txtType.text = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).name; } RarityIconController.UpdateRarityIcon(_ui.m_comTipsBase.m_loaRarity, itemCfg.id, false); ET.Log.Debug(itemCfg.name + " itemId:" + itemCfg.id); } private void UpdateScore() { bool isDressUpOrCard = itemCfg.itemType == ConstItemType.DRESS_UP || itemCfg.itemType == ConstItemType.CARD; _ui.m_comTipsBase.m_loaRarity.visible = isDressUpOrCard; _ui.m_comTipsBase.m_grpScore.visible = isDressUpOrCard; if (!isDressUpOrCard) 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 UpdateTags() { _ui.m_comTipsBase.m_listTag.visible = itemCfg.tagsArr.Length > 0; _ui.m_comTipsBase.m_listTag.numItems = itemCfg.tagsArr.Length; } private void RenderListTagItem(int index, GObject obj) { UI_ListTagItem item = UI_ListTagItem.Proxy(obj); ItemUtil.UpdateTag(item.m_comTag.target, itemCfg.tagsArr[index][0]); item.m_txtTagScore.text = itemCfg.tagsArr[index][1].ToString(); UI_ListTagItem.ProxyEnd(); } private void UpdateItems() { _ui.m_comTipsBase.m_listItem.visible = itemCfg.itemsArr.Length > 0; _ui.m_comTipsBase.m_listItem.numItems = itemCfg.itemsArr.Length; } private void ListItemRenderer(int index, GObject obj) { ItemData itemData = ItemUtil.createItemData(itemCfg.itemsArr[index]); if (obj.data == null) { obj.data = new ItemView(obj as GComponent); } (obj.data as ItemView).SetData(itemData); (obj.data as ItemView).ChangeTxtCountStyle(); } private void UpdateSourec(object[] sourceDatas) { _ui.m_comTipsApproach.target.visible = sourceDatas != null; if (sourceDatas == null) return; approachView.OnShow(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; GComponent 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, "该物品可以在服装店购买,点开服装店看看。"); } } }