123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using FairyGUI;
- using UI.CommonGame;
- using System.Collections;
- 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();
- _ui.m_comTipsDesc.m_txtDesc.text = string.IsNullOrEmpty(itemCfg.desc) ? "暂无描述" : itemCfg.desc;
- UpdateSourec(sourceDatas);
- }
- protected override void OnHide()
- {
- if (approachView != null)
- {
- approachView.OnHide();
- }
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
- }
- private void UpdateBase()
- {
- _ui.m_comTipsBase.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemCfg.id)).FlushVars();
- _ui.m_comTipsBase.m_txtName.text = itemCfg.name;
- if (itemView == null)
- {
- itemView = new ItemView(_ui.m_comTipsBase.m_goodsItem.target);
- }
- ItemData itemData = ItemUtil.createItemData(new int[] { itemCfg.id, 1 });
- itemView.SetData(itemData);
- itemView.ShowCount = false;
- itemView.ShowTips = false;
- itemView.ShowRarity = false;
- }
- private void UpdateScore()
- {
- bool isDressUp = itemCfg.itemType == ConstItemType.DRESS_UP;
- _ui.m_comTipsBase.m_rarity.visible = isDressUp;
- _ui.m_comTipsScores.target.visible = isDressUp;
- if (!isDressUp) return;
- _ui.m_comTipsScores.m_txtGong.text = "" + itemCfg.score1;
- _ui.m_comTipsScores.m_txtShang.text = "" + itemCfg.score2;
- _ui.m_comTipsScores.m_txtJue.text = "" + itemCfg.score3;
- _ui.m_comTipsScores.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);
- }
- }
- }
|