| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | | using System;
|
| | |
|
| | | using UnityEngine; |
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class TrialExchangeCell : CellView
|
| | | {
|
| | | [SerializeField] ItemCell m_Item;
|
| | | [SerializeField] Text m_Description;
|
| | | [SerializeField] ItemBehaviour m_Token;
|
| | | [SerializeField] Button m_Exchange;
|
| | | [SerializeField] Image m_Redpoint;
|
| | | [SerializeField] TrialExchangeBehaviour[] m_TrialExchanges;
|
| | |
|
| | | TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
|
| | | DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
| | |
|
| | | int trialExchangeId = 0;
|
| | | private void Awake()
|
| | | public void Display(int _class, int _line)
|
| | | {
|
| | | m_Exchange.AddListener(Exchange);
|
| | | }
|
| | |
|
| | | private void Exchange()
|
| | | {
|
| | | if (trialExchangeId != 0)
|
| | | List<TrialExchangeConfig> list;
|
| | | if (!model.TryGetTrialExchanges(_class, out list))
|
| | | {
|
| | | 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(() =>
|
| | | int _betterEquipId = -1;
|
| | | model.IsAnySatisfyExchangeBetterEquip(_class, out _betterEquipId);
|
| | | for (int i = 0; i < m_TrialExchanges.Length; i++)
|
| | | {
|
| | | 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);
|
| | |
|
| | | var count = model.GetTrialTokenCount(config.tokenId);
|
| | | m_Redpoint.gameObject.SetActive(count >= config.tokenCount
|
| | | && dailyQuestModel.trialExchangeRedpoint.state == RedPointState.Simple);
|
| | | var index = _line * 4 + i;
|
| | | if (index < list.Count)
|
| | | {
|
| | | m_TrialExchanges[i].gameObject.SetActive(true);
|
| | | m_TrialExchanges[i].Display(list[index].id, _betterEquipId == list[index].id);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_TrialExchanges[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } |