12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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<WidgetItem>(rewardPool);
- }
- private Action onClose;
- private string rewardPool = "rewardPool";
-
- public async void InitRewardsPanel(List<ItemInfo> rewards, Action onClose = null)
- {
- this.onClose = onClose;
- foreach (ItemInfo reward in rewards)
- {
- GenerateWidget(reward);
- }
- }
- public async void InitRewardsPanel(Dictionary<string, ItemInfo> rewardsDic, Action onClose = null)
- {
- this.onClose = onClose;
- foreach (KeyValuePair<string,ItemInfo> keyValuePair in rewardsDic)
- {
- GenerateWidget(keyValuePair.Value);
- }
- }
- private async void GenerateWidget(ItemInfo itemInfo)
- {
- WidgetItem widgetItem = await UIManager.Instance.CreateGComponentForObject<WidgetItem>(widget, null, isInstance: true,
- poolName: rewardPool, root: itemRoot);
- widgetItem.InitWidget(itemInfo);
- }
- }
- }
|