123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using System.Collections.Generic;
- using Core.Utility;
- using Fort23.Core;
- using GameLogic.Combat.CombatTool;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "ShopPanel")]
- public partial class ShopPanel : UIPanel
- {
- private List<AccountFileInfo.ShopData> _shopDatas;
- private List<ShopGroupWidgetType1> _shopGroupWidgetType1s = new List<ShopGroupWidgetType1>();
- List<EnergyWidget> _energyWidgets = new List<EnergyWidget>();
- // public bool isPauseCombat;
- private void Init()
- {
- isAddStack = true;
- }
- protected override void AddEvent()
- {
- EventManager.Instance.AddEventListener(CustomEventType.ShopRefence, ShopRefence);
- }
- protected override void DelEvent()
- {
- EventManager.Instance.RemoveEventListener(CustomEventType.ShopRefence, ShopRefence);
- }
- public override CTask GetFocus()
- {
- AppBarPanel.OpenPanel(this);
- return base.GetFocus();
- }
- public override CTask<bool> AsyncInit(object[] uiData)
- {
- // isPauseCombat = uiData[0] as bool? == true;
- return base.AsyncInit(uiData);
- }
- public async override CTask Show()
- {
- await base.Show();
- // if (isPauseCombat)
- // {
- // if (CombatController.currActiveCombat != null)
- // CombatController.currActiveCombat.isUpdate = false;
- // }
- foreach (var widget in _energyWidgets)
- {
- UIManager.Instance.DormancyGComponent(widget);
- }
- _energyWidgets.Clear();
- EnergyWidget energyWidget =
- await UIManager.Instance.CreateGComponent<EnergyWidget>(null, Group_ResourceBar);
- energyWidget.CustomInit(GlobalParam.Item_Coin_ID);
- _energyWidgets.Add(energyWidget);
- energyWidget = await UIManager.Instance.CreateGComponent<EnergyWidget>(null, Group_ResourceBar);
- energyWidget.CustomInit(GlobalParam.Item_Diamond_ID);
- _energyWidgets.Add(energyWidget);
- }
- private void ShopRefence(IEventData e)
- {
- CustomInit();
- }
- public override void AddButtonEvent()
- {
- Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel<ShopPanel>(); });
- }
- public async CTask CustomInit()
- {
- var dic = new Dictionary<string, string>();
- // YouLoftSDK.Instance.CustomEvent("OpenShopPanel", dic);
- foreach (var shopGroupWidgetType1 in _shopGroupWidgetType1s)
- {
- UIManager.Instance.DormancyGComponent(shopGroupWidgetType1);
- }
- _shopGroupWidgetType1s.Clear();
- _shopDatas = ShopManger.Instance.GetAllShopConfig();
- foreach (var shopData in _shopDatas)
- {
- // if (shopData.id == 1 || shopData.id == 5)
- // {
- // ShopGroupWidgetType1 shopGroupWidgetType1 =
- // await UIManager.Instance.CreateGComponentForObject<ShopGroupWidgetType1>(ShopGroupWidgetType1,
- // null, Content, isInstance: true);
- // _shopGroupWidgetType1s.Add(shopGroupWidgetType1);
- // await shopGroupWidgetType1.CustomInit(shopData);
- // }
- // else
- {
- ShopGroupWidgetType1 shopGroupWidgetType1 =
- await UIManager.Instance.CreateGComponentForObject<ShopGroupWidgetType1>(ShopGroupWidgetType2,
- null, Content, isInstance: true);
- _shopGroupWidgetType1s.Add(shopGroupWidgetType1);
- await shopGroupWidgetType1.CustomInit(shopData);
- }
- }
- }
- public override void Close()
- {
- // if (isPauseCombat)
- // {
- // if (CombatController.currActiveCombat != null)
- // CombatController.currActiveCombat.isUpdate = true;
- // }
- foreach (var shopGroupWidgetType1 in _shopGroupWidgetType1s)
- {
- UIManager.Instance.DormancyGComponent(shopGroupWidgetType1);
- }
- _shopGroupWidgetType1s.Clear();
- foreach (var widget in _energyWidgets)
- {
- UIManager.Instance.DormancyGComponent(widget);
- }
- _energyWidgets.Clear();
- // MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- // if (mainUIPanel != null)
- // {
- // mainUIPanel.shopDatas = AccountFileInfo.Instance.playerData.shopDatas;
- // mainUIPanel.FindShop();
- // }
- base.Close();
- }
- public static async CTask<ShopPanel> OpenPanel(bool isPauseCombat = false)
- {
- ShopPanel shopPanel = await UIManager.Instance.LoadAndOpenPanel<ShopPanel>(null, uiData: new object[] { isPauseCombat });
- await shopPanel.CustomInit();
- return shopPanel;
- }
- }
- }
|