| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 | using System;using System.Collections.Generic;using System.Linq;using Core.Language;using Excel2Json;using Fort23.Core;using Fort23.UTool;using GameLogic.Combat;using GameLogic.Combat.CombatTool;namespace Fort23.Mono{    [UIBinding(prefab = "PlacesInfoPanel")]    public partial class PlacesInfoPanel : UIPanel    {        private int PlacesId;        private SmallPlacesConfig smallPlacesConfig;        private PlacesConfig placesConfig;        List<ShopBtnWidget> _shopBtnWidgets = new List<ShopBtnWidget>();        private Action<bool> callBack;        private bool isChange;        private void Init()        {            isPopUi = true;            isAddStack = false;        }        protected override void AddEvent()        {        }        protected override void DelEvent()        {        }        public override void AddButtonEvent()        {            Btn_Go.onClick.AddListener(Click_Go);            Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });        }        public async override CTask<bool> AsyncInit(object[] uiData)        {            PlacesId = (int)(uiData[0]);            callBack = uiData[1] as Action<bool>;            isChange = false;            // smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(PlacesId);            placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(PlacesId);            foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds)            {                ShopBtnWidget shopBtnWidget =                    await UIManager.Instance.CreateGComponentForObject<ShopBtnWidget>(ShopBtnWidgetGame, null, Content,                        isInstance: true);                shopBtnWidget.CustomInit(placesConfigSmallPlacersId);                shopBtnWidget.OnClick = OnClick;                _shopBtnWidgets.Add(shopBtnWidget);            }            bool isSelect = false;            for (var i = 0; i < _shopBtnWidgets.Count; i++)            {                if (PlayerManager.Instance.CurrentsmallPlaces.id == _shopBtnWidgets[i].SmallPlacesConfig.ID)                {                    isSelect = true;                    _shopBtnWidgets[i].OnPointerClick();                    break;                }            }            if (!isSelect)            {                for (var i = _shopBtnWidgets.Count - 1; i >= _shopBtnWidgets.Count; i--)                {                    if (_shopBtnWidgets[i].iaUlock)                    {                        _shopBtnWidgets[i].OnPointerClick();                        break;                    }                }            }            // toggleList.GetChildObj();            BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(placesConfig.bigMapID);            Text_BigMapName.text = LanguageManager.Instance.Text(bigMapConfig.mapName);            Text_PlacesName.text = LanguageManager.Instance.Text(placesConfig.placeName);            // int triggerCount = 0;            // foreach (var i in placesConfig.MainTaskID)            // {            //     if (EventSystemManager.Instance.IsEventTrigger(i))            //     {            //         triggerCount++;            //     }            // }            AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(placesConfig.ID);            int jindu = placesData == null ? 0 : placesData.progress;            Text_PlacesComplteProgress.text = $"章节事件:{jindu}/{placesConfig.TotalScore}";            return await base.AsyncInit(uiData);        }        private void OnClick(ItemWidgetBasic obj)        {            ShopBtnWidget shopBtnWidget = obj as ShopBtnWidget;            AccountFileInfo.SmallPlacesData lastSmallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(shopBtnWidget.SmallPlacesConfig.ID - 1);            SmallPlacesConfig lastSmallPlacesConfig =                ConfigComponent.Instance.Get<SmallPlacesConfig>(shopBtnWidget.SmallPlacesConfig.ID - 1);            if (shopBtnWidget.SmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||                                                           lastSmallPlacesData.completionEventCount <                                                           lastSmallPlacesConfig.CompletionEventCount))            {                TipMessagePanel.OpenTipMessagePanel(                    $"[{LanguageManager.Instance.Text(shopBtnWidget.SmallPlacesConfig.placeName)}]未解锁, 完成{lastSmallPlacesConfig.CompletionEventCount}个任务后, 可解锁. ");                return;            }            if (lastSmallPlacesConfig.UnlockEnvetid != 0)            {                AccountFileInfo.EventList eventList =                    AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>                        ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);                if (eventList == null || !eventList.isCompleted)                {                    EventConfig eventConfig =                        ConfigComponent.Instance.Get<EventConfig>(lastSmallPlacesConfig.UnlockEnvetid);                    TipMessagePanel.OpenTipMessagePanel(                        $"[{LanguageManager.Instance.Text(smallPlacesConfig.placeName)}]未解锁, 主线任务{eventConfig.EventName}后, 可解锁. ");                    return;                }            }            AccountFileInfo.SmallPlacesData currentSmallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(shopBtnWidget.SmallPlacesConfig.ID);            if (currentSmallPlacesData == null)            {                TipMessagePanel.OpenTipMessagePanel("通过上一个地点解锁");                return;            }            AccountFileInfo.SmallPlacesData nextSmallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(shopBtnWidget.SmallPlacesConfig.ID + 1);            //解锁下一个地图            if (nextSmallPlacesData == null && IsSmallPlacesDataUlock(shopBtnWidget.SmallPlacesConfig.ID + 1))            {                Text_Go.text = "解锁下一地点";            }            else            {                Text_Go.text = "前往";            }            // toggleList.ClickWidget(shopBtnWidget.uiToggle);            smallPlacesConfig = shopBtnWidget.SmallPlacesConfig;            AccountFileInfo.SmallPlacesData smallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID);            Slider_SmallJD.maxValue = smallPlacesConfig.CompletionEventCount;            float tansuodu = smallPlacesData == null ? 0 : smallPlacesData.completionEventCount;            Slider_SmallJD.value = tansuodu;            Text_TanSuDu.text =                $"[{LanguageManager.Instance.Text(smallPlacesConfig.placeName)}]探索度 {(tansuodu / smallPlacesConfig.CompletionEventCount) * 100}%";        }        private bool IsSmallPlacesDataUlock(int id)        {            AccountFileInfo.SmallPlacesData lastSmallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(id - 1);            SmallPlacesConfig lastSmallPlacesConfig =                ConfigComponent.Instance.Get<SmallPlacesConfig>(id - 1);            if (id > 1 && (lastSmallPlacesData == null ||                           lastSmallPlacesData.completionEventCount <                           lastSmallPlacesConfig.CompletionEventCount))            {                return false;            }            if (lastSmallPlacesConfig.UnlockEnvetid != 0)            {                AccountFileInfo.EventList eventList =                    AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>                        ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);                if (eventList == null || !eventList.isCompleted)                {                    return false;                }            }            return true;        }        private async void Click_Go()        {            if (smallPlacesConfig.ID == 0)                return;            AccountFileInfo.SmallPlacesData nextSmallPlacesData =                PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID + 1);            //解锁下一个地图            if (nextSmallPlacesData == null && IsSmallPlacesDataUlock(smallPlacesConfig.ID + 1))            {                isChange = true;                await UIManager.Instance.HideUIUIPanel<LevelChoosePanel>();                await UIManager.Instance.HideUIUIPanel(this);                //切换下一个地图                await PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID + 1);                // PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.PlacesId);                PlacesChangeInfoPanel placesChangeInfoPanel =                    await PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.ID + 1);                await placesChangeInfoPanel.UIClosed();                // CombatDrive.Instance.CombatController.ChangeState(CombatController.update);                // CombatController.currActiveCombat.CombatHeroController.Flight(2, -90, 10);                // UIManager.Instance.SetEventSystemEnable(false);                // await TimerComponent.Instance.WaitAsync(2 * 1000 + 1200);                // CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);                // UIManager.Instance.SetEventSystemEnable(true);                callBack?.Invoke(true);                callBack = null;            }            else            {                AccountFileInfo.SmallPlacesData lastSmallPlacesData =                    PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1);                SmallPlacesConfig lastSmallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesConfig.ID - 1);                if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||                                                 lastSmallPlacesData.completionEventCount <                                                 lastSmallPlacesConfig.CompletionEventCount))                {                    TipMessagePanel.OpenTipMessagePanel(                        $"[{LanguageManager.Instance.Text(smallPlacesConfig.placeName)}]未解锁, 完成{lastSmallPlacesConfig.CompletionEventCount}个任务后, 可解锁. ");                    return;                }                if (lastSmallPlacesConfig.UnlockEnvetid != 0)                {                    AccountFileInfo.EventList eventList =                        AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>                            ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);                    EventConfig eventConfig =                        ConfigComponent.Instance.Get<EventConfig>(lastSmallPlacesConfig.UnlockEnvetid);                    if (eventList == null || !eventList.isCompleted)                    {                        TipMessagePanel.OpenTipMessagePanel(                            $"[{LanguageManager.Instance.Text(smallPlacesConfig.placeName)}]未解锁, 主线任务{eventConfig.EventName}后, 可解锁. ");                        return;                    }                }                if (smallPlacesConfig.ID == PlayerManager.Instance.CurrentsmallPlaces.id)                {                    await UIManager.Instance.HideUIUIPanel<LevelChoosePanel>();                    await UIManager.Instance.HideUIUIPanel(this);                    return;                }                isChange = true;                await UIManager.Instance.HideUIUIPanel<LevelChoosePanel>();                await UIManager.Instance.HideUIUIPanel(this);                await PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID);                PlacesChangeInfoPanel placesChangeInfoPanel =                    await PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.ID);                await placesChangeInfoPanel.UIClosed();                callBack?.Invoke(true);                callBack = null;            }        }        public static async CTask OpenPanel(int placesId, Action<bool> callBack)        {            await UIManager.Instance.LoadAndOpenPanel<PlacesInfoPanel>(null, UILayer.Top,                uiData: new object[] { placesId, callBack }, isShowBG: true);        }        public async override CTask Close()        {            foreach (var shopBtnWidget in _shopBtnWidgets)            {                UIManager.Instance.DormancyGComponent(shopBtnWidget);            }            _shopBtnWidgets.Clear();            // smallPlacesConfig = default;            if (!isChange)            {                callBack?.Invoke(false);                callBack = null;            }            await base.Close();        }    }}
 |