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(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 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 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.CreateGComponent(null, poolName: rewardPool, root: itemRoot); widgetItem.InitWidget(itemInfo); } public async static CTask OpenPanel(Dictionary rewardsDic, Action onClose = null) { RewardsPanel rewardsPanel = await UIManager.Instance.LoadAndOpenPanel(null, layer: UILayer.Top); rewardsPanel.InitRewardsPanel(rewardsDic, onClose); return rewardsPanel; } public async static CTask OpenPanel(List rewardsDic, Action onClose = null, int titleId = 0) { RewardsPanel rewardsPanel = await UIManager.Instance.LoadAndOpenPanel(null, layer: UILayer.Top); rewardsPanel.InitRewardsPanel(rewardsDic, onClose); if (titleId != 0) rewardsPanel.SetTitle(LanguageManager.Instance.Text(titleId)); return rewardsPanel; } } }