using ET; using FairyGUI; using UnityEngine; namespace GFGGame { public class ItemView { private GComponent _obj; private GComponent _item; private GLoader _loaIcon; private GLoader _loaRarity; private GTextField _txtName; private GTextField _txtCount; // private GImage _imgGot; private GGroup _grpGot; private GImage _imgNotHas; private GImage _imgHas; private GImage _imgShouTong; private GImage _imgNum; private Controller _qualityType; private Controller _scaleType; // private GGroup _grpCount; private bool _showTips = true; private ItemData _itemData; public ItemView(GComponent obj) { _obj = obj; _item = obj.GetChild("comItemIcon").asCom; _loaIcon = _item.GetChild("loaIcon") as GLoader; _loaRarity = _item.GetChild("loaRarity") as GLoader; _txtName = obj.GetChild("txtName") as GTextField; _txtCount = _item.GetChild("txtCount") as GTextField; // _imgGot = obj.GetChild("imgGot") as GImage; _grpGot = _item.GetChild("grpGot") as GGroup; _imgNotHas = _item.GetChild("imgNotHas") as GImage; _imgHas = _item.GetChild("imgHas") as GImage; _imgShouTong = _item.GetChild("imgShowTong") as GImage; _imgNum = _item.GetChild("imgNum") as GImage; _qualityType = _item.GetController("QualityType") as Controller; _scaleType = _item.GetController("ScaleType") as Controller; // _grpCount = obj.GetChild("grpCount") as GGroup; // AddClickListener(); _item.onClick.Remove(AddClickListener); _item.onClick.Add(AddClickListener); } public void Dispose() { _item.onClick.Remove(AddClickListener); _item.Dispose(); } private void AddClickListener() { if (!ShowTips) return; GoodsItemTipsController.ShowItemTips(_itemData.id); } public void SetData(ItemData itemData) { _itemData = itemData; UpdateView(); } private void UpdateView() { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemData.id); if (itemCfg == null) { Log.Error($"使用了一个不存在的物品 {_itemData.id}!"); return; } _loaIcon.url = string.IsNullOrEmpty(itemCfg.res) ? "" : ResPathUtil.GetIconPath(itemCfg); RarityIconController.UpdateRarityIcon(_loaRarity, _itemData.id, false); // _imgGot.visible = false; _txtName.visible = false; _grpGot.visible = false; _imgNotHas.visible = false; _imgHas.visible = false; _imgShouTong.visible = false; // _grpCount.visible = true; _showTips = true; _txtCount.visible = true; _imgNum.visible = true; _txtName.text = itemCfg.name; _txtCount.text = string.Format("{0}", _itemData.num); if(itemCfg.rarity > 0) _qualityType.selectedIndex = itemCfg.rarity - 1; } public ItemData ItemData { get { return _itemData; } } public GComponent GetGComponentObj { get { return _obj; } } /// /// “已领取”显示状态 /// /// public bool GrpGotVisible { get { return _grpGot.visible; } set { _grpGot.visible = value; } } /// “已获得”显示状态 /// /// public bool ImgHasVisible { get { return _imgHas.visible; } set { _imgHas.visible = value; } } /// /// “未获得”显示状态 /// /// public bool ImgNotGotVisible { get { return _imgNotHas.visible; } set { _imgNotHas.visible = value; } } /// /// /// "首通奖励"显示状态 /// /// public bool ImgShouTongVisable { get { return _imgShouTong.visible; } set { _imgShouTong.visible = value; } } /// /// 显示名字 /// /// public bool ShowName { set { _txtName.visible = value; } } /// /// 显示稀有度 /// /// public bool ShowRarity { set { _loaRarity.visible = value; } } // /// // /// 显示数量 // /// // /// // public bool ShowCount // { // set // { // _grpCount.visible = value; // } // } /// /// 展示详情tips /// /// public bool ShowTips { get { return _showTips; } set { _showTips = value; } } public float SetComItemScale { set { _item.SetScale(value, value); } } public float SetTxtCountScale { set { _txtCount.SetScale(value, value); _imgNum.SetScale(value, value); } } public float SetTxtNameScale { set { _txtName.SetScale(value, value); } } public void SetTxtCountPos(int x, int y) { _txtCount.SetPosition(x, y, 0); } public bool ShowTxtCount { set { _txtCount.visible = value; _imgNum.visible = value; } } public void ChangeTxtCountStyle() { _txtCount.text = string.Format("{0}", _itemData.num); } public void SetTxtNamePos(int x, int y) { _txtName.SetPosition(x, y, 0); } } }