using System.Collections.Generic; using System.Linq; using Core.Language; using Excel2Json; using Fort23.Core; using Fort23.UTool; 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 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]); // smallPlacesConfig = ConfigComponent.Instance.Get(PlacesId); placesConfig = ConfigComponent.Instance.Get(PlacesId); foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds) { ShopBtnWidget shopBtnWidget = await UIManager.Instance.CreateGComponent(null, Content); 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); Text_PlacesComplteProgress.text = $"完成度:{PlayerManager.Instance.GetMapBl(placesConfig.ID)}%"; return await base.AsyncInit(uiData); } private void OnClick(ItemWidgetBasic obj) { ShopBtnWidget shopBtnWidget = obj as ShopBtnWidget; toggleList.ClickWidget(shopBtnWidget.uiToggle); smallPlacesConfig = shopBtnWidget.SmallPlacesConfig; } private async void Click_Go() { if (smallPlacesConfig.ID == 0) return; 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("上一个关卡事件完成度不足"); return; } if (smallPlacesConfig.UnlockEnvetid != 0) { AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == smallPlacesConfig.UnlockEnvetid); if (eventList == null || !eventList.isCompleted) { TipMessagePanel.OpenTipMessagePanel("主线任务没有完成"); return; } } AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID); if (smallPlacesData == null) { smallPlacesData = new AccountFileInfo.SmallPlacesData(); smallPlacesData.id = smallPlacesConfig.ID; AccountFileInfo.Instance.playerData.smallPlacesDatas.Add(smallPlacesData); } AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.ID); if (currentPlacesData == null) { currentPlacesData = new AccountFileInfo.PlacesData(); currentPlacesData.id = placesConfig.ID; AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData); } PlayerManager.Instance.CurrentsmallPlaces = smallPlacesData; UIManager.Instance.HideUIUIPanel(); UIManager.Instance.HideUIUIPanel(this); EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null); } public static async CTask OpenPanel(int placesId) { await UIManager.Instance.LoadAndOpenPanel(null, UILayer.Top, uiData: new object[] { placesId }, isShowBG: true); } public override void Close() { foreach (var shopBtnWidget in _shopBtnWidgets) { UIManager.Instance.DormancyGComponent(shopBtnWidget); } _shopBtnWidgets.Clear(); smallPlacesConfig = default; base.Close(); } } }