123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- 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<WorldMapConfig>(bigMapId);
- _bigMapItem = new BigMapItem();
- GameObjectPool gameObjectPool2 = await GObjectPool.Instance.FetchAsync<GameObjectPool>(worldMapConfig.bigMapPrefabName + ".prefab");
- gameObjectPool2.own.transform.parent = MapRoot;
- gameObjectPool2.own.transform.localScale = Vector3.one;
- gameObjectPool2.own.transform.GetComponent<RectTransform>().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<BigMapConfig>(bigMapId);
- GameObjectPool gameObjectPool2 = await GObjectPool.Instance.FetchAsync<GameObjectPool>(bigMapConfig.mapPrefabName + ".prefab");
- gameObjectPool2.own.transform.parent = PlacesRoot ;
- gameObjectPool2.own.transform.localScale = Vector3.one;
- gameObjectPool2.own.transform.GetComponent<RectTransform>().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<PlacesConfig>(PlacesId);
- BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(placesConfig.bigMapID);
- await ChangeMap(bigMapConfig.ID);
- ChangePlaces(bigMapConfig.ID);
- }
- public async static CTask OpenPanel()
- {
- LevelChoosePanel levelChoosePanel = await UIManager.Instance.LoadAndOpenPanel<LevelChoosePanel>(null);
- levelChoosePanel.CustomInit();
- }
- public override void Close()
- {
- placesItem?.Dispose();
- placesItem = null;
- _bigMapItem?.Dispose();
- _bigMapItem = null;
- base.Close();
- }
- }
- }
|