using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class PutawayItem : MonoBehaviour
|
{
|
[SerializeField] Button m_Buy;
|
[SerializeField] Text m_Price;
|
[SerializeField] Image m_ItemBG;
|
[SerializeField] Image m_ItemIcon;
|
[SerializeField] Text m_ItemName;
|
[SerializeField] Text m_ItemCount;
|
[SerializeField] Transform[] m_Stars;
|
|
public void Init(MarketItemData data, Action<MarketItemData> callback)
|
{
|
ItemConfig config = Config.Instance.Get<ItemConfig>((int)data.ItemTypeID);
|
int uintprice = (int)data.PriceCount / data.Count;
|
if (uintprice < 1)
|
{
|
m_Price.text = "<1";
|
}
|
else
|
{
|
m_Price.text = data.PriceCount.ToString();
|
}
|
m_Buy.onClick.RemoveAllListeners();
|
m_Buy.onClick.AddListener(() =>
|
{
|
if (callback != null)
|
{
|
callback(data);
|
}
|
});
|
if (config != null)
|
{
|
m_ItemName.text = config.ItemName;
|
var itemColor = config.ItemColor;
|
if (config.Type == 111)//翅膀
|
{
|
itemColor = UIHelper.GetItemColor(config.ID, ConfigParse.Analysis(data.UserData));
|
}
|
m_ItemBG.SetItemBackGround(itemColor);
|
bool _bright = (m_ItemName is RichText) ? (m_ItemName as RichText).colorType == RichText.ColorType.Bright : true;
|
m_ItemName.color = UIHelper.GetUIColor(itemColor, _bright);
|
m_ItemIcon.SetSprite(config.IconKey);
|
for (int i = 0; i < m_Stars.Length; i++)
|
{
|
if (i < config.StarLevel)
|
{
|
m_Stars[i].gameObject.SetActive(true);
|
}
|
else
|
{
|
m_Stars[i].gameObject.SetActive(false);
|
}
|
}
|
}
|
if (data.Count == 1)
|
{
|
m_ItemCount.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_ItemCount.gameObject.SetActive(true);
|
m_ItemCount.text = data.Count.ToString();
|
}
|
}
|
}
|
}
|