| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 | using System;using System.Collections.Generic;using System.Linq;using Core.Audio;using Core.Language;using Core.Utility;using Excel2Json;using Fort23.Core;using Fort23.UTool;using GameLogic.Bag;using UnityEngine;using Random = UnityEngine.Random;namespace Fort23.Mono{    [UIBinding(prefab = "GachaPanel")]    public partial class GachaPanel : UIPanel    {        List<WidgetItemType2> widgetItems = new List<WidgetItemType2>();        private List<ItemInfo> itemInfos;        private int type;        private OpenBoxConfig _openBoxConfig;        private WidgetItemType2 widgetItem;        private AccountFileInfo.SummonData SummonData;        private void Init()        {            isAddStack = true;            IsShowAppBar = false;        }        public override CTask GetFocus()        {            AppBarPanel.ClosePanel();            TitlePanel.ClosePanel();            // TitlePanel.OpenPanel(new List<int>() { GlobalParam.Item_Coin_ID, GlobalParam.Item_Diamond_ID });            return base.GetFocus();        }        public override CTask LoseFocus()        {            TitlePanel.ClosePanel();            return base.LoseFocus();        }        protected override void AddEvent()        {        }        protected override void DelEvent()        {        }        public override void AddButtonEvent()        {            tenButton.onClick.AddListener(() =>            {                tenButton.gameObject.SetActive(false);                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);                }                if (itemInfos.Count == 1)                {                    widgetItem.Play(beLv);                }                else                {                    foreach (var widgetItemType2 in widgetItems)                    {                        widgetItemType2.Play(beLv);                    }                }                Text_Tips.text = $"已获得{beLv}倍奖励";                Text_Tips.gameObject.SetActive(true);                // UIManager.Instance.HideUIUIPanel<GachaPanel>();            });            Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel<GachaPanel>(); });        }        public async override CTask<bool> AsyncInit(object[] uiData)        {            Text_Tips.gameObject.SetActive(false);            itemInfos = uiData[0] as List<ItemInfo>;            type = (int)uiData[1];            _openBoxConfig = ConfigComponent.Instance.Get<OpenBoxConfig>((int)uiData[2]);            SummonData = PlayerManager.Instance.SummonManager.summonDataMap[_openBoxConfig.ID];            Slider_Count.maxValue = _openBoxConfig.reward2para1;            Slider_Count.value = SummonData.baodiCount2;            Text_Count.text = $"{SummonData.baodiCount2}/{_openBoxConfig.reward2para1}";            StartRoot.gameObject.SetActive(SummonData.isSummonSocre);            if (SummonData.isSummonSocre)            {                Text_JingDu.text = LanguageManager.Instance.Text(10260, SummonData.drawHistory.Count * 10,                    _openBoxConfig.ProgressRewardChoukaCount);                Text_Score.text = LanguageManager.Instance.Text(10261, SummonData.score);                OpenBoxScoreRule openBoxScoreRule = CheckAchievements(SummonData);                if (openBoxScoreRule.ID != 0)                {                    ScoreRoot.SetActive(true);                    Text_ScoreName.text = LanguageManager.Instance.Text(openBoxScoreRule.lanID);                    Text_ScoreCount.text = $"+{openBoxScoreRule.score}";                    Slider_Score2.maxValue = _openBoxConfig.ProgressRewardChoukaCount;                    Slider_Score1.maxValue = _openBoxConfig.ProgressRewardChoukaCount;                    Slider_Score2.value = SummonData.drawHistory.Count * 10;                    Slider_Score1.value = (SummonData.drawHistory.Count - 1) * 10;                }                else                {                    ScoreRoot.SetActive(false);                }            }            else            {                ScoreRoot.SetActive(false);            }            return await base.AsyncInit(uiData);        }        private float timer = 0;        public async CTask CusstomInit()        {            await MarskPanel.OpenPanel();            tenButton.gameObject.SetActive(true);            if (itemInfos.Count > 1)            {                TenRoot.gameObject.SetActive(true);                OneRoot.gameObject.SetActive(false);                // await TimerComponent.Instance.WaitAsync(600);                for (var i = 0; i < itemInfos.Count; i++)                {                    WidgetItemType2 widgetItem =                        await UIManager.Instance.CreateGComponentForObject<WidgetItemType2>(TenWidgetitems[i], null);                    widgetItem.InitWidget(itemInfos[i]);                    widgetItem.own.SetActive(true);                    widgetItems.Add(widgetItem);                    await TimerComponent.Instance.WaitAsync(50);                }            }            if (itemInfos.Count == 1)            {                for (var i = 0; i < itemInfos.Count; i++)                {                    widgetItem =                        await UIManager.Instance.CreateGComponentForObject<WidgetItemType2>(WidgetItemType2Gam, null);                    widgetItem.InitWidget(itemInfos[i]);                }                TenRoot.gameObject.SetActive(false);                OneRoot.gameObject.SetActive(true);            }            await MarskPanel.ClosePanel();            root.gameObject.SetActive(true);        }        // 检查成就匹配        private OpenBoxScoreRule CheckAchievements(AccountFileInfo.SummonData summonData)        {            List<OpenBoxScoreRule> openBoxScoreRuleList =                PlayerManager.Instance.SummonManager.openBoxScoreRuleMap[summonData.id];            List<OpenBoxScoreRule> daChengOpenBoxScoreRuleList = new List<OpenBoxScoreRule>();            foreach (var openBoxScoreRule in openBoxScoreRuleList)            {                // 检查连续 Para0 次十连                if (summonData.drawHistory.Count < openBoxScoreRule.para0) continue;                bool allDrawsSatisfy = true;                // 检查最近 Para0 次十连是否都满足条件                for (int i = summonData.drawHistory.Count - openBoxScoreRule.para0;                     i < summonData.drawHistory.Count;                     i++)                {                    if (!PlayerManager.Instance.SummonManager.CheckSingleDraw(openBoxScoreRule,                            summonData.drawHistory[i].list))                    {                        allDrawsSatisfy = false;                        break;                    }                }                if (allDrawsSatisfy)                {                    daChengOpenBoxScoreRuleList.Add(openBoxScoreRule);                }            }            if (daChengOpenBoxScoreRuleList.Count > 0)            {                int id = daChengOpenBoxScoreRuleList.Max(obsr => obsr.ID);                OpenBoxScoreRule openBoxScoreRule = ConfigComponent.Instance.Get<OpenBoxScoreRule>(id);                return openBoxScoreRule;            }            return default;        }        public async override CTask Close()        {            // foreach (var widgetItem in widgetItems)            // {            //     UIManager.Instance.DormancyGComponent(widgetItem);            // }            //            // widgetItems.Clear();            tenButton.gameObject.SetActive(false);            tenButton.gameObject.SetActive(false);            OneRoot.gameObject.SetActive(true);            //完成挑战过后自动打开挑战界面            if (_openBoxConfig.ProgressRewardChoukaCount != -1 &&                SummonData.drawHistory.Count * 10 >= _openBoxConfig.ProgressRewardChoukaCount)            {                OpenBoxScorePanel.OpenPanel();            }            foreach (var tenWidgetitem in TenWidgetitems)            {                tenWidgetitem.gameObject.SetActive(false);            }            root.gameObject.SetActive(false);            await base.Close();        }        public async static CTask<GachaPanel> OpenPanel(List<ItemInfo> itemInfos, int type, int configId)        {            GachaPanel gachaPanel = await UIManager.Instance.LoadAndOpenPanel<GachaPanel>(null, UILayer.Middle,                uiData: new object[] { itemInfos, type, configId }, isShowBG: false);            // await TimerComponent.Instance.WaitAsync(300);            gachaPanel.CusstomInit();            AudioManager.Instance.PlayAudio("ui_chouqugongfa.wav");            return gachaPanel;        }    }}
 |