using System.Collections.Generic; using Core.Language; using Core.Utility; using Excel2Json; using Fort23.Core; using Fort23.UTool; using GameLogic.Bag; using GameLogic.Combat.CombatTool; using GameLogic.Player; using UnityEngine; namespace Fort23.Mono { public static class BoxHelper { public async static CTask> TenBox(int configId, bool isFree = false) { OpenBoxConfig openBoxConfig = ConfigComponent.Instance.Get(configId); if (PlayerManager.Instance.BagController.IsEnough(GlobalParam.Item_Coin_ID, openBoxConfig.tenConsume) || isFree) { PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.tenConsume); List allIitem = new List(); for (int i = 0; i < 10; i++) { List currItem = DropManager.Instance.DropItem(openBoxConfig.reward); allIitem.AddRange(currItem); } PlayerManager.Instance.BagController.AddItem(allIitem); return allIitem; } else { bool isOK = await TipsPanle.OpenPnael(1041); if (isOK) { ShopPanel.OpenPanel(); } return null; } } public async static CTask> OneBox(int configId) { OpenBoxConfig openBoxConfig = ConfigComponent.Instance.Get(configId); if (PlayerManager.Instance.BagController.IsEnough(GlobalParam.Item_Coin_ID, openBoxConfig.oneConsume)) { PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.oneConsume); List allIitem = DropManager.Instance.DropItem(openBoxConfig.reward); PlayerManager.Instance.BagController.AddItem(allIitem); return allIitem; } else { bool isOK = await TipsPanle.OpenPnael(1041); if (isOK) { ShopPanel.OpenPanel(); } // TipMessagePanel.OpenTipMessagePanel(LanguageManager.Instance.Text(102), Vector2.zero); return null; } } } [UIBinding(prefab = "BoxPanel")] public partial class BoxPanel : UIPanel { private OpenBoxConfig openBoxConfig; public static async void OpenBoxPanel() { BoxPanel boxPanel = await UIManager.Instance.LoadAndOpenPanel(null, layer: UILayer.Top); boxPanel.OpenPanel(); } private void Init() { isAddStack = false; IsShowAppBar = false; } protected override void AddEvent() { } protected override void DelEvent() { } private bool isStartAd = false; public override void AddButtonEvent() { oneButton.onClick.AddListener(OnButtonCallBack); tenButton.onClick.AddListener(TenButtonCallBack); close.onClick.AddListener(CloseButtonCallBack); bg.onClick.AddListener(CloseButtonCallBack); Btn_AdsFree.onClick.AddListener(async () => { if (AccountFileInfo.Instance.playerData.boxFree) { TipMessagePanel.OpenTipMessagePanel(938, Vector2.zero); return; } if (isStartAd) return; isStartAd = true; var dic = new Dictionary(); dic.Add("Chouka", ""); // YouLoftSDK.Instance.CustomEvent("OnclickAds", dic); // bool isOK = await YouLoftSDK.Instance.ShowAd(); bool isOK = true; isStartAd = false; if (!isOK) { return; } dic = new Dictionary(); dic.Add("Chouka", ""); // YouLoftSDK.Instance.CustomEvent("AdsPlayOver", dic); AccountFileInfo.Instance.playerData.boxFree = true; AccountFileInfo.Instance.SavePlayerData(); Btn_AdsFree.gameObject.SetActive(false); List allIitem = await BoxHelper.TenBox(openBoxConfig.ID, true); if (allIitem != null) GachaPanel.OpenPanel(allIitem, 2, openBoxConfig.ID); }); } private async void OnButtonCallBack() { //测试代码 List allIitem = await BoxHelper.OneBox(openBoxConfig.ID); if (allIitem != null) GachaPanel.OpenPanel(allIitem, 1, openBoxConfig.ID); } private async void TenButtonCallBack() { //测试代码 List allIitem = await BoxHelper.TenBox(openBoxConfig.ID); if (allIitem != null) GachaPanel.OpenPanel(allIitem, 2, openBoxConfig.ID); } private void CloseButtonCallBack() { UIManager.Instance.HideUIUIPanel(this); EventManager.Instance.Dispatch(CustomEventType.Combat_EquipFall, null); } public override void Close() { CombatController.currActiveCombat.isUpdate = true; base.Close(); } public void OpenPanel() { CombatController.currActiveCombat.isUpdate = false; openBoxConfig = ConfigComponent.Instance.Get(1); onCion.text = "x" + openBoxConfig.oneConsume; tenCion.text = "x" + openBoxConfig.tenConsume; if (AccountFileInfo.Instance.playerData.boxFree) { Btn_AdsFree.gameObject.SetActive(false); } else { Btn_AdsFree.gameObject.SetActive(true); } } } }