using Excel2Json; using Fort23.Core; using Fort23.UTool; using UnityEngine; namespace Fort23.Mono { [UIBinding(prefab = "LevelChoosePanel")] public partial class LevelChoosePanel : UIPanel { private BigMapItem _bigMapItem; private PlacesItem placesItem; private void Init() { isAddStack = true; IsShowAppBar = false; } protected override void AddEvent() { } protected override void DelEvent() { } public override void AddButtonEvent() { Btn_RenJie.onClick.AddListener(async () => { ChangeMap(1); }); Btn_Close.onClick.AddListener(() => { if (placesItem != null) { placesItem?.Dispose(); placesItem = null; Sv2.gameObject.SetActive(false); return; } else { UIManager.Instance.HideUIUIPanel(this); } }); } public async CTask ChangeMap(int bigMapId) { Sv2.gameObject.SetActive(false); _bigMapItem?.Dispose(); _bigMapItem = null; WorldMapConfig worldMapConfig = ConfigComponent.Instance.Get(bigMapId); _bigMapItem = new BigMapItem(); GameObjectPool gameObjectPool2 = await GObjectPool.Instance.FetchAsync(worldMapConfig.bigMapPrefabName + ".prefab"); gameObjectPool2.own.transform.parent = MapRoot; gameObjectPool2.own.transform.localScale = Vector3.one; gameObjectPool2.own.transform.GetComponent().anchoredPosition = Vector2.zero; _bigMapItem.CustomInit(worldMapConfig.ID, gameObjectPool2, BigMapOnClick); } private async void BigMapOnClick(ItemWidgetBasic obj) { BigMapWidget bigMapWidget = obj as BigMapWidget; ChangePlaces(bigMapWidget.bigMap.ID); } private async void PlacesOnClick(ItemWidgetBasic obj) { PlacesWidget placesWidget = obj as PlacesWidget; //加载地图 AccountFileInfo.PlacesData lastPlacesData = PlayerManager.Instance.GetPlacesData(placesWidget.placesConfig.ID - 1); if (placesWidget.placesConfig.ID > 1 && (lastPlacesData == null || lastPlacesData.progress < 100)) { TipMessagePanel.OpenTipMessagePanel("上一个关卡没有解锁"); return; } AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(placesWidget.placesConfig.ID); if (currentPlacesData == null) { currentPlacesData = new AccountFileInfo.PlacesData(); currentPlacesData.id = placesWidget.placesConfig.ID; AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData); } PlayerManager.Instance.CurrentPlaces = currentPlacesData; UIManager.Instance.HideUIUIPanel(this); EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null); } public async void ChangePlaces(int bigMapId) { Sv2.gameObject.SetActive(true); placesItem?.Dispose(); placesItem = null; BigMapConfig bigMapConfig = ConfigComponent.Instance.Get(bigMapId); GameObjectPool gameObjectPool2 = await GObjectPool.Instance.FetchAsync(bigMapConfig.mapPrefabName + ".prefab"); gameObjectPool2.own.transform.parent = PlacesRoot ; gameObjectPool2.own.transform.localScale = Vector3.one; gameObjectPool2.own.transform.GetComponent().anchoredPosition = Vector2.zero; placesItem = new PlacesItem(); placesItem.CustomInit(bigMapConfig.ID, gameObjectPool2, PlacesOnClick); } public async void CustomInit() { int PlacesId = PlayerManager.Instance.GetMaxPlacesId(); PlacesConfig placesConfig = ConfigComponent.Instance.Get(PlacesId); BigMapConfig bigMapConfig = ConfigComponent.Instance.Get(placesConfig.bigMapID); await ChangeMap(bigMapConfig.ID); ChangePlaces(bigMapConfig.ID); } public async static CTask OpenPanel() { LevelChoosePanel levelChoosePanel = await UIManager.Instance.LoadAndOpenPanel(null); levelChoosePanel.CustomInit(); } public override void Close() { placesItem?.Dispose(); placesItem = null; _bigMapItem?.Dispose(); _bigMapItem = null; base.Close(); } } }