|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using Snxxz.UI;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
public class GridCell : MonoBehaviour
|
{
|
private BagItemCell _itemCell;
|
public BagItemCell itemCell {
|
get
|
{
|
if(_itemCell == null)
|
_itemCell = transform.Find("ItemCell").GetComponent<BagItemCell>();
|
return _itemCell;
|
}
|
}
|
|
private GameObject _gridLock;
|
public GameObject gridLock {
|
get { return _gridLock ?? (_gridLock = transform.Find("GridLock").gameObject); }
|
}
|
|
private Image _cdImage;
|
public Image cdImag {get { return _cdImage ?? (_cdImage = transform.Find("CDImag").GetComponent<Image>()); }}
|
|
private ButtonExtend _itemCellBtn;
|
public ButtonExtend itemCellBtn { get { return _itemCellBtn ?? (_itemCellBtn = transform.Find("ItemCell/Container_ItemCell").GetComponent<ButtonExtend>()); } }
|
|
private Button _lockBtn;
|
public Button lockBtn { get { return _lockBtn ?? (_lockBtn = transform.Find("GridLock").GetComponent<Button>()); } }
|
|
private UIEffect _uiEffect;
|
public UIEffect uiEffect
|
{
|
get { return _uiEffect ?? (_uiEffect = transform.Find("UIEffect").GetComponent<UIEffect>()); }
|
}
|
|
|
private ItemModel itemModel = null;
|
|
public void SetModel(ItemModel itemModel)
|
{
|
this.itemModel = itemModel;
|
}
|
|
private void OnEnable()
|
{
|
KnapsackTimeCDMgr.Instance.RefresCoolTimeAct += RefreshItemCDTime;
|
}
|
|
private void OnDisable()
|
{
|
KnapsackTimeCDMgr.Instance.RefresCoolTimeAct -= RefreshItemCDTime;
|
}
|
|
private void RefreshItemCDTime(string guid)
|
{
|
ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(guid);
|
if (itemModel == null || cool == null || itemModel.config.CDType == 0) return;
|
|
ItemConfig itemConfig = ItemConfig.Get(cool.itemId);
|
if (itemModel.config.CDType != itemConfig.CDType) return;
|
|
if (cool.GetRemainTime() > 0)
|
{
|
cdImag.gameObject.SetActive(true);
|
cdImag.fillAmount = (float)cool.GetRemainTime() / (itemModel.config.CDTime / 1000);
|
}
|
else
|
{
|
cdImag.fillAmount = 0;
|
cdImag.gameObject.SetActive(false);
|
}
|
}
|
}
|
}
|