using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System;
|
|
namespace vnxbqy.UI
|
{
|
public class DayOnlineCell : CellView
|
{
|
[SerializeField] Text m_TimeInfo;
|
[SerializeField] ItemCell[] m_Items;
|
[SerializeField] Image m_StateImg;
|
[SerializeField] ButtonEx m_GetBtn;
|
[SerializeField] UIEffect m_GetEffect;
|
|
DayOnlineModel model { get { return ModelCenter.Instance.GetModel<DayOnlineModel>(); } }
|
|
public void Display(int index)
|
{
|
//原索引对应的物品奖励;index是排序后的索引
|
int realIndex = Array.IndexOf(model.timeArr, model.indexSort[index]) + 1;
|
|
for (int i = 0; i < m_Items.Length; i++)
|
{
|
if (model.awards.ContainsKey(realIndex) && i < model.awards[realIndex].Count)
|
{
|
m_Items[i].SetActive(true);
|
var itemID = model.awards[realIndex][i][0];
|
var itemCount = model.awards[realIndex][i][1];
|
|
var Item = ItemConfig.Get(itemID);
|
ItemCellModel cellModel = new ItemCellModel(itemID, true, (ulong)itemCount);
|
m_Items[i].Init(cellModel);
|
m_Items[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
|
}
|
else
|
{
|
m_Items[i].SetActive(false);
|
}
|
}
|
|
m_TimeInfo.text = Language.Get("dayOnline_2", model.indexSort[index]);
|
m_GetEffect.SetActive(false);
|
m_GetEffect.Stop();
|
var state = model.GetAwardState(realIndex - 1);
|
if (state == 2)
|
{
|
m_StateImg.SetActive(true);
|
m_GetBtn.SetActive(false);
|
}
|
else
|
{
|
m_StateImg.SetActive(false);
|
m_GetBtn.SetActive(true);
|
if (state == 0)
|
{
|
m_GetEffect.SetActive(true);
|
m_GetEffect.Play();
|
}
|
m_GetBtn.SetColorful(null, state == 0);
|
|
m_GetBtn.SetListener(() => {
|
CA506_tagCMGetOnlinePrize pack = new CA506_tagCMGetOnlinePrize();
|
pack.Index = (byte)realIndex;
|
pack.IsDaily = 1;
|
GameNetSystem.Instance.SendInfo(pack);
|
});
|
}
|
}
|
}
|
}
|