using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class SingleRechargeSumCell : CellView
|
{
|
[SerializeField] Text m_Consume;
|
[SerializeField] RareItem[] m_RebateItems;
|
[SerializeField] Button m_GetBtn;
|
[SerializeField] UIEffect m_GetSfx;
|
[SerializeField] Image m_GotSign;
|
|
SingleRechargeSumModel model { get { return ModelCenter.Instance.GetModel<SingleRechargeSumModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
|
public void Display(int _index)
|
{
|
OperationBase operationBase;
|
if (OperationTimeHepler.Instance.TryGetOperationTime(SingleRechargeSumModel.operType, out operationBase))
|
{
|
OperationSingleRecharge operation = operationBase as OperationSingleRecharge;
|
var keys = operation.singleRechargeAwards.Keys.ToList();
|
keys.Sort();
|
|
var awards = operation.singleRechargeAwards[keys[_index]];
|
|
m_Consume.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(keys[_index]));
|
|
for (int i = 0; i < m_RebateItems.Length; i++)
|
{
|
if (i < awards.Count)
|
{
|
var itemDate = awards[i];
|
m_RebateItems[i].SetActive(true);
|
ItemCellModel itemCell = new ItemCellModel(itemDate.id, true, (ulong)itemDate.count);
|
m_RebateItems[i].Init(itemCell);
|
m_RebateItems[i].button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemDate.id);
|
});
|
}
|
else
|
{
|
m_RebateItems[i].SetActive(false);
|
}
|
}
|
|
int state = model.GetRewardState(_index);
|
|
m_GetBtn.SetActive(state != 2);
|
m_GetBtn.interactable = state == 1;
|
m_GetBtn.SetColorful(null, state == 1);
|
m_GotSign.SetActive(state == 2);
|
m_GetSfx.SetActive(state == 1);
|
|
m_GetBtn.AddListener(() => {
|
GetReward(_index);
|
});
|
|
Text activityCountText = m_Consume.FindComponent("Text", "Text_AllCount") as Text;
|
Text canGetCountText = m_Consume.FindComponent("Text", "Text_CanCount") as Text;
|
|
int maxCount = model.GetMaxRewardCnt(index);
|
int canGetCount = model.GetCanRewardGetCnt(index);
|
int gotCount = model.GetRewardGotCnt(index);
|
|
activityCountText.text = Language.Get("SingleRecharge2", maxCount - canGetCount, maxCount);
|
if (canGetCount - gotCount <= 0)
|
{
|
canGetCountText.text = string.Empty;
|
}
|
else
|
{
|
canGetCountText.text = Language.Get("SingleRecharge3", canGetCount - gotCount);
|
}
|
}
|
}
|
|
private void GetReward(int index)
|
{
|
OperationBase operationBase;
|
if (OperationTimeHepler.Instance.TryGetOperationTime(SingleRechargeSumModel.operType, out operationBase))
|
{
|
var operation = operationBase as OperationSingleRecharge;
|
}
|
var count = packModel.GetEmptyGridCount(PackType.Item);
|
if (count < 4)
|
{
|
SysNotifyMgr.Instance.ShowTip("BagFull");
|
return;
|
}
|
model.SendGetReward(index);
|
}
|
}
|
}
|
|