Files
JJBB/Assets/Project/Script/GUI/BackPack/CommonItemMaterialSlot.cs

149 lines
4.2 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using GCGame.Table;
using Games.Mission;
using Games.Events;
using Games.Item;
using GCGame;
using Module.Log;
public class CommonItemMaterialSlot : CommonItemContainerItem
{
public Text _ItemName;
public Text _ItemNum;
public GameObject _GetPathGO;
private GameItem _Item;
public int _ItemDataID;
private bool _IsEnough;
private int _NeedNum;
public int NeedNum
{
get
{
return _NeedNum;
}
}
private bool _ShowItemName;
private bool _IsMoneyEnought;
public override void Init()
{
_ShowItemName = _ItemName.gameObject.activeSelf;
LogModule.DebugLog("_ShowItemName:" + _ShowItemName);
}
public override void Show(Hashtable hash)
{
base.Show();
_Item = (GameItem)hash["InitObj"];
InitItem(_ItemParam);
_ShowItemName = _ItemName.gameObject.activeSelf;
}
public void ClearItem()
{
m_ItemImg.gameObject.SetActive(false);
_ItemName.gameObject.SetActive(false);
m_ItemQuality.gameObject.SetActive(false);
_ItemNum.gameObject.SetActive(false);
_GetPathGO.SetActive(false);
}
public void InitMaterial(int dataId, int needNum, bool onlyBind = false, int matCnt = -1)
{
int itemCount = matCnt;
if (matCnt < 0)
{
itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(dataId);
}
_ItemDataID = dataId;
_NeedNum = needNum;
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(dataId, 0);
if (commonItem != null)
{
if (_ShowItemName)
{
_ItemName.gameObject.SetActive(true);
}
_ItemName.text = commonItem.Name;
m_ItemImg.gameObject.SetActive(true);
_ItemNum.gameObject.SetActive(true);
LoadAssetBundle.Instance.SetImageSprite(m_ItemImg, commonItem.Icon);
m_ItemQuality.gameObject.SetActive(true);
LoadAssetBundle.Instance.SetImageSprite(m_ItemQuality, Utils.GetItemQualityFrame(commonItem));
if (commonItem.QualityEffect > 0)
{
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, m_ItemImg.transform);
}
else
{
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, m_ItemImg.transform);
}
if (itemCount >= _NeedNum)
{
_ItemNum.text = /*StrDictionary.GetClientDictionaryString("#{5525}") + */itemCount + /*"</color>*/"/" + _NeedNum;
_GetPathGO.SetActive(false);
_IsEnough = true;
}
else
{
_ItemNum.text = /*StrDictionary.GetClientDictionaryString("#{5526}")*/ + itemCount + /*"</color>*/"/" + _NeedNum;
_GetPathGO.SetActive(true);
_IsEnough = false;
}
return;
}
else
{
ClearItem();
}
}
public void UpdateNum(int matCnt = -1)
{
int itemCount = matCnt;
if (matCnt < 0)
{
itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(_ItemDataID);
}
if (itemCount >= _NeedNum)
{
_ItemNum.text = StrDictionary.GetClientDictionaryString("#{5525}") + itemCount + "</color>/" + _NeedNum;
_GetPathGO.SetActive(false);
_IsEnough = true;
}
else
{
_ItemNum.text = StrDictionary.GetClientDictionaryString("#{5526}") + itemCount + "</color>/" + _NeedNum;
_GetPathGO.SetActive(true);
_IsEnough = false;
}
}
public bool IsMaterialEnough()
{
return _IsEnough;
}
public override void OnItemClick()
{
base.OnItemClick();
ItemTooltipsLogic.ShowItemTooltip(_ItemDataID, ItemTooltipsLogic.ShowType.Info, transform.position);
}
public void ShowGetPath()
{
ItemTooltipsLogic.ShowItemTooltip(_ItemDataID, ItemTooltipsLogic.ShowType.GetPath, transform.position);
}
}