121 lines
3.6 KiB
C#
121 lines
3.6 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Mission;
|
|||
|
using Games.Events;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class LiveItemMaterial
|
|||
|
{
|
|||
|
public int DataID;
|
|||
|
public int NeedNum;
|
|||
|
}
|
|||
|
|
|||
|
public class LiveSkillMaterialItem : CommonItemContainerItem
|
|||
|
{
|
|||
|
|
|||
|
public Text _ItemNum;
|
|||
|
public GameObject _GetPathGO;
|
|||
|
|
|||
|
private LiveItemMaterial _MaterialInfo;
|
|||
|
public int _ItemDataID;
|
|||
|
private bool _IsEnough;
|
|||
|
private int _NeedNum;
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
base.Show();
|
|||
|
|
|||
|
_MaterialInfo = (LiveItemMaterial)hash["InitObj"];
|
|||
|
InitMaterial(_MaterialInfo.DataID, _MaterialInfo.NeedNum);
|
|||
|
}
|
|||
|
|
|||
|
public void ClearItem()
|
|||
|
{
|
|||
|
m_ItemImg.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)
|
|||
|
{
|
|||
|
var itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(dataId);
|
|||
|
_ItemDataID = dataId;
|
|||
|
_NeedNum = needNum;
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(dataId, 0);
|
|||
|
if (commonItem != null)
|
|||
|
{
|
|||
|
m_ItemImg.gameObject.SetActive(true);
|
|||
|
_ItemNum.gameObject.SetActive(true);
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(m_ItemImg, commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(m_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem));
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, m_ItemImg.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, m_ItemImg.transform);
|
|||
|
}
|
|||
|
|
|||
|
//m_ItemQuality.gameObject.SetActive(false);
|
|||
|
//LoadAssetBundle.Instance.SetImageSprite(m_ItemQuality, Games.GlobeDefine.GlobeVar.QualityColorGrid[commonItem.Quality - 1]);
|
|||
|
if (itemCount >= _NeedNum)
|
|||
|
{
|
|||
|
_ItemNum.text = "<color=#5bd55b>" + itemCount + "</color>/" + _NeedNum;
|
|||
|
_GetPathGO.SetActive(false);
|
|||
|
_IsEnough = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_ItemNum.text = "<color=#ff1100>" + itemCount + "</color>/" + _NeedNum;
|
|||
|
_GetPathGO.SetActive(true);
|
|||
|
_IsEnough = false;
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ClearItem();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateNum()
|
|||
|
{
|
|||
|
var itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(_ItemDataID);
|
|||
|
if (itemCount >= _NeedNum)
|
|||
|
{
|
|||
|
_ItemNum.text = "<color=#5bd55b>" + itemCount + "</color>/" + _NeedNum;
|
|||
|
_GetPathGO.SetActive(false);
|
|||
|
_IsEnough = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_ItemNum.text = "<color=#ff1100>" + itemCount + "</color>/" + _NeedNum;
|
|||
|
_GetPathGO.SetActive(true);
|
|||
|
_IsEnough = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool IsMaterialEnough()
|
|||
|
{
|
|||
|
return _IsEnough;
|
|||
|
}
|
|||
|
|
|||
|
public void ShowGetPath()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_ItemDataID, ItemTooltipsLogic.ShowType.LiveSkillGet, transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public override void OnItemClick()
|
|||
|
{
|
|||
|
base.OnItemClick();
|
|||
|
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_ItemDataID, ItemTooltipsLogic.ShowType.Info, transform.position);
|
|||
|
}
|
|||
|
}
|