You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.5 KiB
94 lines
2.5 KiB
using UnityEngine;
|
|
using TMPro;
|
|
using IVDataFormat;
|
|
using System.Collections.Generic;
|
|
|
|
public class IVPpGoods : MonoBehaviour
|
|
{
|
|
protected RectTransform rtrfSelf;
|
|
protected TextMeshProUGUI txtTitle;
|
|
protected GoodsNameItem[] goodsNameItems;
|
|
|
|
protected System.Action actionBtnYes;
|
|
|
|
public bool IsOpen()
|
|
{
|
|
return gameObject.activeSelf;
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
rtrfSelf = GetComponent<RectTransform>();
|
|
txtTitle = rtrfSelf.Find("titlebg").transform.Find("txtTitle").GetComponent<TextMeshProUGUI>();
|
|
goodsNameItems = rtrfSelf.Find("wrapper").GetComponentsInChildren<GoodsNameItem>(true);
|
|
}
|
|
|
|
public void Open(IList<nGoods> goods, System.Action actionyes = null, string strtitle = null, float ftime = 0f)
|
|
{
|
|
CancelInvoke(nameof(Close));
|
|
|
|
if (string.IsNullOrEmpty(strtitle))
|
|
strtitle = LocalizationText.GetText(Global.STR_REWARDGET);
|
|
|
|
txtTitle.text = strtitle;
|
|
actionBtnYes = actionyes;
|
|
|
|
if (goods.Count <= 11)
|
|
{
|
|
Vector2 v2size = rtrfSelf.sizeDelta;
|
|
v2size.y = 200f;
|
|
rtrfSelf.sizeDelta = v2size;
|
|
GameUIMgr.SetLineSML(1);
|
|
}
|
|
else if (goods.Count <= 22)
|
|
{
|
|
Vector2 v2size = rtrfSelf.sizeDelta;
|
|
v2size.y = 340f;
|
|
rtrfSelf.sizeDelta = v2size;
|
|
GameUIMgr.SetLineSML(2);
|
|
}
|
|
else
|
|
{
|
|
Vector2 v2size = rtrfSelf.sizeDelta;
|
|
v2size.y = 480f;
|
|
rtrfSelf.sizeDelta = v2size;
|
|
GameUIMgr.SetLineSML(3);
|
|
}
|
|
|
|
for (int i = 0; i < goodsNameItems.Length; i++)
|
|
{
|
|
if (i >= goods.Count)
|
|
{
|
|
goodsNameItems[i].gameObject.SetActive(false);
|
|
continue;
|
|
}
|
|
goodsNameItems[i].SetData(goods[i]);
|
|
goodsNameItems[i].gameObject.SetActive(true);
|
|
}
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
if (ftime > 0f)
|
|
Invoke(nameof(Close), ftime);
|
|
}
|
|
|
|
protected void Close()
|
|
{
|
|
GameUIMgr.SOnClosePopup();
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void BtnYesPressed()
|
|
{
|
|
CancelInvoke(nameof(Close));
|
|
GameUIMgr.SOnClosePopup();
|
|
gameObject.SetActive(false);
|
|
for (int i = 0; i < goodsNameItems.Length; i++)
|
|
{
|
|
goodsNameItems[i].ReleaseData();
|
|
}
|
|
|
|
if (actionBtnYes != null)
|
|
actionBtnYes.Invoke();
|
|
}
|
|
}
|