using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//特权卡
|
public class PrivilegeCardCell : MonoBehaviour
|
{
|
[SerializeField] Transform[] tqLines;
|
[SerializeField] Text[] tqTexts;
|
[SerializeField] ItemCell[] itemCells;
|
[SerializeField] ItemCell[] dayItemCells;
|
[SerializeField] Text timeText;
|
[SerializeField] Button opBtn;
|
[SerializeField] Text opBtnText;
|
|
|
|
public void Display(int type)
|
{
|
var lines = InvestModel.Instance.GetPrivilegeLins(type);
|
for (int i = 0; i < tqLines.Length; i++)
|
{
|
if (i < lines)
|
{
|
tqLines[i].SetActive(true);
|
tqTexts[i].text = Language.Get($"PrivilegeCard{type}_{i+1}");
|
}
|
else
|
{
|
tqLines[i].SetActive(false);
|
}
|
}
|
|
var ctgID = InvestModel.Instance.GetCTGID(type);
|
var ctgConfig = CTGConfig.Get(ctgID);
|
for (int i = 0; i < itemCells.Length; i++)
|
{
|
if (i < ctgConfig.GainItemList.Length)
|
{
|
itemCells[i].SetActive(true);
|
int itemID = ctgConfig.GainItemList[i][0];
|
itemCells[i].Init(new ItemCellModel(itemID, false, ctgConfig.GainItemList[i][1]));
|
itemCells[i].button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
}
|
else
|
{
|
itemCells[i].SetActive(false);
|
}
|
}
|
|
var dayAwards = InvestModel.Instance.GetDayAwards(type);
|
for (int i = 0; i < dayItemCells.Length; i++)
|
{
|
if (i < dayAwards.Length)
|
{
|
dayItemCells[i].SetActive(true);
|
int itemID = dayAwards[i][0];
|
dayItemCells[i].Init(new ItemCellModel(itemID, false, dayAwards[i][1]));
|
dayItemCells[i].button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
}
|
else
|
{
|
dayItemCells[i].SetActive(false);
|
}
|
}
|
|
var state = InvestModel.Instance.GetInvestState(type);
|
|
if (timeText != null)
|
{
|
if (state == 0)
|
{
|
timeText.text = "";
|
}
|
else
|
{
|
timeText.text = Language.Get("GoldRush29") + TimeUtility.SecondsToShortDHMS(InvestModel.Instance.GetInvestLeftTime(type));
|
}
|
}
|
|
if (state == 0)
|
{
|
var orderInfo = InvestModel.Instance.GetOrderInfo(type);
|
opBtnText.text = Language.Get("PayMoneyNum", orderInfo.PayRMBNumOnSale);
|
opBtn.SetInteractable(true);
|
opBtn.AddListener(() =>
|
{
|
RechargeManager.Instance.CTG(ctgID);
|
});
|
}
|
else if (state == 1)
|
{
|
opBtnText.text = Language.Get("Mail09");
|
opBtn.SetInteractable(true);
|
opBtn.AddListener(() =>
|
{
|
InvestModel.Instance.SendGetReward(type);
|
});
|
}
|
else
|
{
|
if (type == 1)
|
{
|
var orderInfo = InvestModel.Instance.GetOrderInfo(type);
|
opBtnText.text = Language.Get("PayMore", orderInfo.PayRMBNumOnSale);
|
opBtn.SetInteractable(true);
|
opBtn.AddListener(() =>
|
{
|
if (InvestModel.Instance.IsBuyMaxDay(type))
|
{
|
SysNotifyMgr.Instance.ShowTip("BuyIsMax");
|
return;
|
}
|
RechargeManager.Instance.CTG(ctgID);
|
});
|
}
|
else
|
{
|
opBtn.SetInteractable(false);
|
opBtnText.text = Language.Get("L1129_2");
|
}
|
}
|
}
|
|
|
public void UpdateTime(int type)
|
{
|
var state = InvestModel.Instance.GetInvestState(type);
|
if (state == 0)
|
{
|
return;
|
}
|
if (timeText != null)
|
{
|
timeText.text = Language.Get("GoldRush29") + TimeUtility.SecondsToShortDHMS(InvestModel.Instance.GetInvestLeftTime(type));
|
}
|
}
|
|
}
|