84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class AutoMedicItem : MonoBehaviour {
|
|||
|
|
|||
|
|
|||
|
public Image _itemQuality;
|
|||
|
public Image _ItemIcon;
|
|||
|
public Text _ItemName;
|
|||
|
public Text _ItemDesc;
|
|||
|
public Text _itemCount;
|
|||
|
public GameObject _getPathIcon;
|
|||
|
public GameObject _markIcon;
|
|||
|
|
|||
|
private bool _isSelected = true; //默认是选中
|
|||
|
private int _itemDataId;
|
|||
|
public void InitItem(int itemId, bool isSelect)
|
|||
|
{
|
|||
|
_isSelected = isSelect;
|
|||
|
_itemDataId = itemId;
|
|||
|
var commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
|||
|
if(commonItem == null)
|
|||
|
{
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_itemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
|
|||
|
var m_AutoUseItem = TableManager.GetAutoUseItemByID(itemId, 0);
|
|||
|
if (m_AutoUseItem != null)
|
|||
|
{
|
|||
|
_ItemName.text = m_AutoUseItem.Name;
|
|||
|
_ItemDesc.text = m_AutoUseItem.Desc;
|
|||
|
}
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, _ItemIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, _ItemIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
var backPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|||
|
_itemCount.text = backPack.GetItemCountByDataId(itemId).ToString();
|
|||
|
_getPathIcon.SetActive(backPack.GetItemCountByDataId(itemId) > 0 ? false : true);
|
|||
|
|
|||
|
RefreshMarkIcon(_isSelected);
|
|||
|
}
|
|||
|
|
|||
|
public void RefreshMarkIcon(bool isSelect)
|
|||
|
{
|
|||
|
_isSelected = isSelect;
|
|||
|
_markIcon.SetActive(_isSelected);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemGetPathIconClick()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_itemDataId, ItemTooltipsLogic.ShowType.GetPath, Vector3.zero, delegate() {
|
|||
|
UIManager.CloseUI(UIInfo.PopAutoMedicItemPanel);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemClick()
|
|||
|
{
|
|||
|
_isSelected = !_isSelected;
|
|||
|
RefreshMarkIcon(_isSelected);
|
|||
|
|
|||
|
if(_isSelected)
|
|||
|
{
|
|||
|
PopAutoMedicItemPanel.Instance.AddItemToItemDateIdList(_itemDataId);
|
|||
|
}else
|
|||
|
{
|
|||
|
PopAutoMedicItemPanel.Instance.RemoveFromItemDateIdList(_itemDataId);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|