using System; using System.Collections.Generic; using GameLogic.Bag; namespace Fort23.Mono { [UIBinding(prefab = "RewardsPanel" )] public partial class RewardsPanel : UIPanel { private void Init() { } protected override void AddEvent() { } protected override void DelEvent() { } public override void AddButtonEvent() { btnDi.onClick.AddListener(OnclickClose); } private void OnclickClose() { onClose?.Invoke(); UIManager.Instance.HideUIUIPanel(this); UIManager.Instance.DormancyAllGComponent(rewardPool); } private Action onClose; private string rewardPool = "rewardPool"; public async void InitRewardsPanel(List rewards, Action onClose = null) { this.onClose = onClose; foreach (ItemInfo reward in rewards) { GenerateWidget(reward); } } public async void InitRewardsPanel(Dictionary rewardsDic, Action onClose = null) { this.onClose = onClose; foreach (KeyValuePair keyValuePair in rewardsDic) { GenerateWidget(keyValuePair.Value); } } private async void GenerateWidget(ItemInfo itemInfo) { WidgetItem widgetItem = await UIManager.Instance.CreateGComponentForObject(widget, null, isInstance: true, poolName: rewardPool, root: itemRoot); widgetItem.InitWidget(itemInfo); } } }