123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using System.Collections.Generic;
- using System.Linq;
- using Core.Language;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Bag;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "ShopGachaPanel")]
- public partial class ShopGachaPanel : UIPanel
- {
- List<WidgetItem> widgetItems = new List<WidgetItem>();
- private List<ItemInfo> itemInfos;
- private int type;
- private OpenBoxConfig _openBoxConfig;
- private AccountFileInfo.SummonData SummonData;
- private int allConit;
- private void Init()
- {
- isAddStack = true;
- IsShowAppBar = false;
- }
- public override CTask GetFocus()
- {
- AppBarPanel.ClosePanel();
- TitlePanel.ClosePanel();
- return base.GetFocus();
- }
- public override CTask LoseFocus()
- {
- TitlePanel.ClosePanel();
- return base.LoseFocus();
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- Btn_ShuangBei.onClick.AddListener(() =>
- {
- float beLv =
- Utility.UtilTools.GetRandomByWeight(_openBoxConfig.betPara1.ToList(), _openBoxConfig.betPara2);
- foreach (var itemInfo in itemInfos)
- {
- ItemInfo itemInfo1 = new ItemInfo(itemInfo.itemID, (long)(itemInfo.count.Value * (beLv - 1)));
- PlayerManager.Instance.BagController.AddItem(itemInfo1);
- }
- Btn_ShuangBei.gameObject.SetActive(false);
- Text_AllCount.text = $"总计:{allConit} x {beLv} = {(int)(allConit * beLv)}";
- Text_Bl.text = $"已获得 <color=#FDB34A>{beLv}</color> 倍奖励";
- Text_Bl.gameObject.SetActive(true);
- // UIManager.Instance.HideUIUIPanel<ShopGachaPanel>();
- });
- Btn_LingQu.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel<ShopGachaPanel>(); });
- }
- public async override CTask<bool> AsyncInit(object[] uiData)
- {
- itemInfos = uiData[0] as List<ItemInfo>;
- type = (int)uiData[1];
- _openBoxConfig = ConfigComponent.Instance.Get<OpenBoxConfig>((int)uiData[2]);
- allConit = 0;
- foreach (var itemInfo in itemInfos)
- {
- if (itemInfo.config.associateID == 9)
- {
- allConit += itemInfo.config.associateVlaue[1];
- }
- }
- Text_AllCount.text = $"总计:{allConit}";
- if (itemInfos.Count > 1)
- {
- for (var i = 0; i < itemInfos.Count; i++)
- {
- DaiJinJuanWidget widgetItem =
- await UIManager.Instance.CreateGComponentForObject<DaiJinJuanWidget>(TenDaiJinJuanWidgetGams[i],
- null);
- widgetItem.CustomInit(itemInfos[i].itemID);
- }
- TenRoot.gameObject.SetActive(true);
- OneRoot.gameObject.SetActive(false);
- }
- if (itemInfos.Count == 1)
- {
- for (var i = 0; i < itemInfos.Count; i++)
- {
- DaiJinJuanWidget widgetItem =
- await UIManager.Instance.CreateGComponentForObject<DaiJinJuanWidget>(DaiJinJuanWidget1Gam,
- null);
- widgetItem.CustomInit(itemInfos[i].itemID);
- }
- TenRoot.gameObject.SetActive(false);
- OneRoot.gameObject.SetActive(true);
- }
- return await base.AsyncInit(uiData);
- }
- public override void Close()
- {
- OneRoot.gameObject.SetActive(false);
- TenRoot.gameObject.SetActive(false);
- Text_Bl.gameObject.SetActive(false);
- Btn_ShuangBei.gameObject.SetActive(true);
- base.Close();
- }
- public async static CTask OpenPanel(List<ItemInfo> itemInfos, int type, int configId)
- {
- if (UIManager.Instance.GetComponent<ShopGachaPanel>() == null ||
- UIManager.Instance.GetComponent<ShopGachaPanel>().IsClose)
- {
- ShopGachaPanel gachaPanel = await UIManager.Instance.LoadAndOpenPanel<ShopGachaPanel>(null,
- UILayer.Middle,
- uiData: new object[] { itemInfos, type, configId }, isShowBG: true);
- }
- }
- }
- }
|