using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
namespace vnxbqy.UI
|
{
|
public class WayCell : MonoBehaviour
|
{
|
[SerializeField] Text m_WayName;
|
[SerializeField] Text m_FunctionName;
|
[SerializeField] Image m_Icon;
|
[SerializeField] Button m_Goto;
|
|
UnityAction onClick;
|
int itemId = 0;
|
int getWay = 0;
|
|
public void Display(int itemId, int getWay)
|
{
|
this.itemId = itemId;
|
this.getWay = getWay;
|
var confg = GetItemWaysConfig.Get(getWay);
|
|
m_Icon.SetSprite(confg.Icon);
|
m_WayName.text = confg.Text;
|
m_FunctionName.text = confg.name;
|
}
|
|
public void AddListener(UnityAction action)
|
{
|
onClick += action;
|
}
|
|
public void RemoveAllListeners()
|
{
|
onClick = null;
|
}
|
|
private void Start()
|
{
|
m_Goto.AddListener(OnClick);
|
}
|
|
private void OnClick()
|
{
|
if (onClick != null)
|
{
|
onClick.Invoke();
|
}
|
|
var config = GetItemWaysConfig.Get(getWay);
|
if (config != null)
|
{
|
|
if (config.customize == 1)
|
{
|
var ItemConfig = StoreConfig.GetStoreCfgByItemID(this.itemId);
|
if (ItemConfig != null)
|
{
|
var storeModel = ModelCenter.Instance.GetModel<StoreModel>();
|
storeModel.SetJumpToModel(this.itemId);
|
if (ItemConfig.SecondType.Length > 0)
|
storeModel.selectSecondType = ItemConfig.SecondType[0];
|
|
}
|
}
|
else if (config.customize/100 == 1)
|
{
|
var storeModel = ModelCenter.Instance.GetModel<StoreModel>();
|
storeModel.SetJumpToModel(this.itemId);
|
storeModel.selectSecondType = config.customize%100;
|
}
|
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.OpenpanelId);
|
}
|
}
|
|
}
|
}
|