Files
back_cantanBuilding/Assets/Scripts/UI/RewardPopup/RewardAlbumAllComplete.cs
2026-05-26 16:15:54 +08:00

66 lines
1.8 KiB
C#

using asap.core;
using game;
using GameCore;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RewardAlbumAllComplete : MonoBehaviour
{
public Transform reward_group;
public Button btnClose;
public TMP_Text text_name;
List<RewardItemNew> items;
public List<ItemData> itemDatas = new List<ItemData>();
private void Awake()
{
reward_group = transform.Find("reward_group");
text_name = transform.Find("album/text_name").GetComponent<TMP_Text>();
btnClose = transform.Find("btn_close").GetComponent<Button>();
}
private void Start()
{
btnClose.onClick.AddListener(OnClickClose);
}
void OnClickClose()
{
GContext.Publish(new ShowData(RewardType.Destroy));
}
public void Show(List<RewardItemNew> rewardItems)
{
items = rewardItems;
GContext.Publish(new VibrationData(HapticTypes.HeavyImpact));
var theme = GContext.container.Resolve<AlbumData>().theme;
if (theme != null)
{
text_name.text = LocalizationMgr.GetText(theme.Title_l10n_key);
}
int itemCount = items.Count;
for (int i = 0; i < itemCount; i++)
{
items[i].gameObject.SetActive(false);
}
for (int i = 0; i < itemDatas.Count; i++)
{
items[i].transform.SetParent(reward_group);
items[i].SetRewardPopupData(itemDatas[i], false);
items[i].PlayOpen();
}
ShowReward();
}
async void ShowReward()
{
await Awaiters.Seconds(2f);
for (int i = 0; i < itemDatas.Count; i++)
{
await items[i].PlayClose();
await items[i].ParticleAttractor();
}
await Awaiters.Seconds(0.4f);
OnClickClose();
}
}