using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
using System;
|
|
namespace Snxxz.UI
|
{
|
public class TrialExchangeCell : CellView
|
{
|
[SerializeField] ItemCell m_Item;
|
[SerializeField] Text m_Description;
|
[SerializeField] ItemBehaviour m_Token;
|
[SerializeField] Button m_Exchange;
|
TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
|
|
int trialExchangeId = 0;
|
private void Awake()
|
{
|
m_Exchange.AddListener(Exchange);
|
}
|
|
private void Exchange()
|
{
|
if (trialExchangeId != 0)
|
{
|
int error = 0;
|
if (!model.TrialSendExchange(trialExchangeId, out error))
|
{
|
if (error == 1)
|
{
|
var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(trialExchangeId);
|
if (config != null)
|
{
|
ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(config.tokenId);
|
}
|
}
|
model.ProcessTrialError(error);
|
}
|
}
|
}
|
|
public void Display(int id)
|
{
|
trialExchangeId = id;
|
var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(id);
|
if (config == null)
|
{
|
trialExchangeId = 0;
|
return;
|
}
|
m_Item.cellBtn.RemoveAllListeners();
|
m_Item.gameObject.SetActive(true);
|
ItemCellModel cellModel = new ItemCellModel(config.exchangeItemID, true, (ulong)config.exchangeItemCount, config.exchangeItemIsBind);
|
m_Item.Init(cellModel);
|
m_Item.cellBtn.AddListener(() =>
|
{
|
ItemAttrData itemAttrData = new ItemAttrData(config.exchangeItemID, true, (ulong)config.exchangeItemCount, -1, config.exchangeItemIsBind);
|
ModelCenter.Instance.GetModel<ItemTipsModel>().SetItemTipsModel(itemAttrData);
|
});
|
m_Description.text = config.description;
|
m_Token.SetItem(config.tokenId, config.tokenCount);
|
}
|
}
|
}
|