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 _shopBtnWidgets = new List(); private Action 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 AsyncInit(object[] uiData) { PlacesId = (int)(uiData[0]); callBack = uiData[1] as Action; isChange = false; // smallPlacesConfig = ConfigComponent.Instance.Get(PlacesId); placesConfig = ConfigComponent.Instance.Get(PlacesId); foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds) { ShopBtnWidget shopBtnWidget = await UIManager.Instance.CreateGComponentForObject(ShopBtnWidgetGame, null, Content, isInstance: true); shopBtnWidget.CustomInit(placesConfigSmallPlacersId); shopBtnWidget.OnClick = OnClick; _shopBtnWidgets.Add(shopBtnWidget); } toggleList.GetChildObj(); _shopBtnWidgets[0].OnPointerClick(); BigMapConfig bigMapConfig = ConfigComponent.Instance.Get(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++; } } Text_PlacesComplteProgress.text = $"章节事件:{triggerCount}/{placesConfig.MainTaskID.Length}"; 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(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(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(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)) { UIManager.Instance.HideUIUIPanel(); UIManager.Instance.HideUIUIPanel(this); //切换下一个地图 PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID + 1); isChange = true; UIManager.Instance.HindCurrAllShowPanel(); 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); UIManager.Instance.ShowLastHindAllShowPanel(); callBack?.Invoke(true); callBack = null; } else { AccountFileInfo.SmallPlacesData lastSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1); SmallPlacesConfig lastSmallPlacesConfig = ConfigComponent.Instance.Get(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(lastSmallPlacesConfig.UnlockEnvetid); if (eventList == null || !eventList.isCompleted) { TipMessagePanel.OpenTipMessagePanel( $"[{LanguageManager.Instance.Text(smallPlacesConfig.placeName)}]未解锁, 主线任务{eventConfig.EventName}后, 可解锁. "); return; } } if (smallPlacesConfig.ID == PlayerManager.Instance.CurrentsmallPlaces.id) { UIManager.Instance.HideUIUIPanel(); UIManager.Instance.HideUIUIPanel(this); return; } isChange = true; PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID); UIManager.Instance.HideUIUIPanel(); UIManager.Instance.HideUIUIPanel(this); UIManager.Instance.HindCurrAllShowPanel(); 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); UIManager.Instance.ShowLastHindAllShowPanel(); callBack?.Invoke(true); callBack = null; } } public static async CTask OpenPanel(int placesId, Action callBack) { await UIManager.Instance.LoadAndOpenPanel(null, UILayer.Top, uiData: new object[] { placesId, callBack }, isShowBG: true); } public override void Close() { foreach (var shopBtnWidget in _shopBtnWidgets) { UIManager.Instance.DormancyGComponent(shopBtnWidget); } _shopBtnWidgets.Clear(); smallPlacesConfig = default; if (!isChange) { callBack?.Invoke(false); callBack = null; } base.Close(); } } }