123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using System;
- using Core.Language;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Equipment;
- using UnityEngine;
- using Utility;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "WidgetItem")]
- public partial class WidgetItem : UIComponent
- {
- public ItemInfo itemInfo;
- private void Init()
- {
- }
- public override void AddEvent()
- {
- }
- public override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- btnClick.onClick.AddListener(OnclickItem);
- }
- private Action onClickItem;
- private async void OnclickItem()
- {
- if (onClickItem != null)
- {
- onClickItem.Invoke();
- return;
- }
- if (itemInfo == null)
- {
- return;
- }
- // ItemPanel itemPanel = await UIManager.Instance.LoadAndOpenPanel<ItemPanel>(null, layer: UILayer.Top);
- // itemPanel.InitItemPanel(itemInfo);
- }
- public void InitWidget(ItemInfo itemInfo, Action onClickItem = null)
- {
- this.itemInfo = itemInfo;
- this.onClickItem = onClickItem;
- border.gameObject.SetActive(false);
- light.gameObject.SetActive(false);
- heroShards.SetActive(false);
- alertRed.SetActive(false);
- icon.gameObject.SetActive(true);
- if (itemInfo.count.Value > 0)
- {
- numObj.SetActive(true);
- num.text = itemInfo.count.Value.ToStringEx();
- }
- else
- {
- numObj.SetActive(false);
- }
- if (itemInfo.eqInfo != null)
- {
- // icon.icon_name = HeroUITools.GetEquipmentIconName(itemInfo);
- lvObj.SetActive(true);
- // txtLv.text = itemInfo.eqInfo.level + "级";
- txtLv.text = LanguageManager.Instance.Text(161, itemInfo.eqInfo.level);
- }
- else if (itemInfo.config.itemTyp == 5)
- {
- heroShards.SetActive(true);
- icon.gameObject.SetActive(false);
- heroShardsIcon.icon_name = itemInfo.config.icon;
- lvObj.SetActive(false);
- }
- else
- {
- icon.icon_name = itemInfo.config.icon;
- lvObj.SetActive(false);
- }
- }
- /// <summary>
- /// 设置单个装备的小红点
- /// </summary>
- /// <param name="oldEq"></param>
- public bool SetEqItemRedPoint(ItemInfo best, int bwIdx)
- {
- //有更好的装备,且装备类型相同
- if (best != null && best.eqInfo.basicEquipConfig.Type == bwIdx)
- {
- alertRed.SetActive(true);
- // if (itemInfo == null)
- // {
- // alertRed.SetActive(true);
- // }
- // //有装备,且装备类型相同,且装备等级更高
- // if (itemInfo != null && best.eqInfo.basicEquipConfig.Type == eqTypIdx)
- // {
- // alertRed.SetActive(true);
- // }
- return true;
- }
- else
- {
- alertRed.SetActive(false);
- }
- return false;
- }
- public void SetEmpty(Action onClickItem = null)
- {
- itemInfo = null;
- this.onClickItem = onClickItem;
- border.gameObject.SetActive(false);
- light.gameObject.SetActive(false);
- numObj.SetActive(false);
- icon.gameObject.SetActive(false);
- corner.gameObject.SetActive(false);
- glow.gameObject.SetActive(false);
- lvObj.SetActive(false);
- heroShards.SetActive(false);
- alertRed.SetActive(false);
- }
- public override void DormancyObj()
- {
- base.DormancyObj();
- }
- }
- }
|