1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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);
- }
- private void OnclickClose()
- {
- onClose?.Invoke();
- UIManager.Instance.HideUIUIPanel(this);
- UIManager.Instance.DormancyAllGComponent<WidgetItem>(rewardPool);
- }
- private Action onClose;
- private string rewardPool = "rewardPool";
- 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 (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 (KeyValuePair<string, ItemInfo> keyValuePair in rewardsDic)
- {
- GenerateWidget(keyValuePair.Value);
- }
- }
- private async void GenerateWidget(ItemInfo itemInfo)
- {
- WidgetItem widgetItem = await UIManager.Instance.CreateGComponent<WidgetItem>(null,
- poolName: rewardPool, root: itemRoot);
- widgetItem.InitWidget(itemInfo);
- }
- public async static CTask<RewardsPanel> OpenPanel(Dictionary<string, ItemInfo> rewardsDic, Action onClose = null)
- {
- RewardsPanel rewardsPanel = await UIManager.Instance.LoadAndOpenPanel<RewardsPanel>(null, layer: UILayer.Top);
- 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);
- rewardsPanel.InitRewardsPanel(rewardsDic, onClose);
- if (titleId != 0)
- rewardsPanel.SetTitle(LanguageManager.Instance.Text(titleId));
- return rewardsPanel;
- }
- }
- }
|