备份CatanBuilding瘦身独立工程
This commit is contained in:
53
Assets/Scripts/UI/Challenge/ChallengeReward.cs
Normal file
53
Assets/Scripts/UI/Challenge/ChallengeReward.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChallangReward : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform tran_rewardParent;
|
||||
[SerializeField]
|
||||
private GameObject go_row;
|
||||
[SerializeField] private PanelScroll ps;
|
||||
|
||||
private List<GameObject> rows = new();
|
||||
int childCount;
|
||||
public async void InitAsync(List<ItemData> dropItems)
|
||||
{
|
||||
childCount = go_row.transform.childCount;
|
||||
go_row.gameObject.SetActive(false);
|
||||
GameObject curParent;
|
||||
for (int i = 0; i < dropItems.Count; i += childCount)
|
||||
{
|
||||
curParent = Instantiate(go_row, tran_rewardParent);
|
||||
curParent.SetActive(true);
|
||||
rows.Add(curParent.gameObject);
|
||||
var count = dropItems.Count - i;
|
||||
for (int j = 0; j < childCount; j++)
|
||||
{
|
||||
curParent.transform.GetChild(j).gameObject.SetActive(j < count);
|
||||
curParent.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
|
||||
}
|
||||
await Awaiters.NextFrame;
|
||||
ps.verticalNormalizedPosition = 0f;
|
||||
for (int j = 0; j < childCount; j++)
|
||||
{
|
||||
if (j < count)
|
||||
{
|
||||
var item = dropItems[i + j];
|
||||
curParent.transform.GetChild(j).gameObject.SetActive(true);
|
||||
var reward = curParent.transform.GetChild(j).GetChild(0).GetComponent<RewardItemNew>();
|
||||
reward.SetRewardPopupData(item);
|
||||
reward.gameObject.SetActive(true);
|
||||
reward.PlayOpen();
|
||||
cfg.Item itemCfg = GContext.container.Resolve<cfg.Tables>().TbItem.GetOrDefault(item.id);
|
||||
GContext.Publish(new ResAddEvent(itemCfg.ID, itemCfg.Type, itemCfg.SubType));
|
||||
}
|
||||
}
|
||||
}
|
||||
await Awaiters.NextFrame;
|
||||
ps.verticalNormalizedPosition = 0f;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user