//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 26, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class EquipStarUpgradeSpecialMaterialBehaviour : MonoBehaviour
|
{
|
[SerializeField] RectTransform m_Empty;
|
[SerializeField] ItemBehaviour m_Item;
|
[SerializeField] Text m_Count;
|
[SerializeField] Button m_AddMaterial;
|
[SerializeField] RectTransform m_Locked;
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
bool isUnLocked = false;
|
int itemId = 0;
|
int itemNeed = 0;
|
|
public void Display(bool isUnLocked, int itemId, int itemNeed)
|
{
|
this.isUnLocked = isUnLocked;
|
this.itemId = itemId;
|
this.itemNeed = itemNeed;
|
|
DisplayBaseInfo();
|
m_AddMaterial.SetListener(AddMaterials);
|
}
|
|
private void DisplayBaseInfo()
|
{
|
m_Locked.gameObject.SetActive(!isUnLocked);
|
if (isUnLocked)
|
{
|
var own = packModel.GetItemCountByID(PackType.Item, itemId);
|
if (own > 0)
|
{
|
m_Item.gameObject.SetActive(true);
|
m_Item.SetItem(itemId, 1);
|
m_Count.gameObject.SetActive(true);
|
m_Count.text = StringUtility.Contact(own, "/", itemNeed);
|
m_Count.color = UIHelper.GetUIColor(own >= itemNeed ? TextColType.Green : TextColType.Red);
|
|
m_Empty.gameObject.SetActive(false);
|
m_AddMaterial.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_Item.gameObject.SetActive(false);
|
m_Count.gameObject.SetActive(false);
|
m_Empty.gameObject.SetActive(true);
|
m_AddMaterial.gameObject.SetActive(true);
|
}
|
}
|
else
|
{
|
m_Empty.gameObject.SetActive(true);
|
m_AddMaterial.gameObject.SetActive(false);
|
m_Item.gameObject.SetActive(false);
|
m_Count.gameObject.SetActive(false);
|
}
|
}
|
|
private void AddMaterials()
|
{
|
ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(itemId);
|
}
|
|
}
|
|
}
|