123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Collections.Generic;
- using Core.Audio;
- using Core.Language;
- using Fort23.Core;
- using GameLogic.Bag;
- using NetCore.Protocol.MemoryPack;
- 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);
- }
-
- List<WidgetItem> widgetItems = new List<WidgetItem>();
- private void OnclickClose()
- {
-
- UIManager.Instance.HideUIUIPanel(this);
-
- }
- public override void Close()
- {
- onClose?.Invoke();
- foreach (var widgetItem in widgetItems)
- {
- UIManager.Instance.DormancyGComponent(widgetItem);
- }
- widgetItems.Clear();
- base.Close();
- }
- private Action onClose;
- public override CTask Show()
- {
- AudioManager.Instance.PlayAudio("jiangliui.wav");
- return base.Show();
- }
- public async void InitRewardsPanel(List<ItemInfo> rewards, Action onClose = null)
- {
- this.onClose = onClose;
- foreach (var widgetItem in widgetItems)
- {
- UIManager.Instance.DormancyGComponent(widgetItem);
- }
- widgetItems.Clear();
- foreach (ItemInfo reward in rewards)
- {
- GenerateWidget(reward);
- }
- }
- public void SetTitle(string title)
- {
- txtlName.text = title;
- }
- public async void InitRewardsPanel(Dictionary<string, ItemInfo> rewardsDic, Action onClose = null)
- {
- this.onClose = onClose;
- foreach (var widgetItem in widgetItems)
- {
- UIManager.Instance.DormancyGComponent(widgetItem);
- }
- widgetItems.Clear();
- foreach (KeyValuePair<string, ItemInfo> keyValuePair in rewardsDic)
- {
- GenerateWidget(keyValuePair.Value);
- }
- }
- private async void GenerateWidget(ItemInfo itemInfo)
- {
- WidgetItem widgetItem = await UIManager.Instance.CreateGComponent<WidgetItem>(null, root: itemRoot);
- widgetItem.InitWidget(itemInfo);
- widgetItems.Add(widgetItem);
- }
- public async static CTask<RewardsPanel> OpenPanel(Dictionary<string, ItemInfo> rewardsDic, Action onClose = null)
- {
- RewardsPanel rewardsPanel = await UIManager.Instance.LoadAndOpenPanel<RewardsPanel>(null, layer: UILayer.Top,isShowBG:true);
- rewardsPanel.InitRewardsPanel(rewardsDic, onClose);
- return rewardsPanel;
- }
- public async static CTask<RewardsPanel> OpenPanel(List<ItemInfo> rewardsDic, Action onClose = null, int titleId = 0)
- {
- RewardsPanel rewardsPanel = await UIManager.Instance.LoadAndOpenPanel<RewardsPanel>(null, layer: UILayer.Top,isShowBG:true);
- rewardsPanel.InitRewardsPanel(rewardsDic, onClose);
- if (titleId != 0)
- rewardsPanel.SetTitle(LanguageManager.Instance.Text(titleId));
- return rewardsPanel;
- }
- }
- }
|