123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using System.Linq;
- using Core.Language;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using UnityEngine;
- using UnityEngine.UI;
- 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;
- //加载地图
- PlacesInfoPanel.OpenPanel(placesWidget.placesConfig.ID);
- //
- // if (placesWidget.placesConfig.ID > 1 && PlayerManager.Instance.GetMapBl(placesWidget.placesConfig.ID - 1) < 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 CTask ChangePlaces(int bigMapId)
- {
- Sv2.gameObject.SetActive(true);
- placesItem?.Dispose();
- placesItem = null;
- BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(bigMapId);
- WorldMapConfig[] worldMapConfigs = ConfigComponent.Instance.GetAll<WorldMapConfig>();
- foreach (var worldMapConfig in worldMapConfigs)
- {
- if (worldMapConfig.bigMapId.Contains(bigMapConfig.ID))
- {
- Text_WorldMapName.text = LanguageManager.Instance.Text(worldMapConfig.worldName);
- break;
- }
- }
- PlacesConfig placesConfig =
- ConfigComponent.Instance.Get<PlacesConfig>(PlayerManager.Instance.CurrentPlaces.id);
- Text_PlacesComplteProgress.text =
- $"{LanguageManager.Instance.Text(placesConfig.placeName)}完成度:{PlayerManager.Instance.PlacesBl}%";
- 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();
- await 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 ChangePlaces(bigMapConfig.ID);
- // await ChangeMap(bigMapConfig.ID);
- Sv2.gameObject.SetActive(true);
- LayoutRebuilder.ForceRebuildLayoutImmediate(PlacesRoot);
- foreach (var placesItemPlacesWidget in placesItem.PlacesWidgets)
- {
- if (placesItemPlacesWidget.placesConfig.ID == PlayerManager.Instance.CurrentPlaces.id)
- {
- // Rect_BiaoJi.anchoredPosition = transform.worldToLocalMatrix * placesItemPlacesWidget.Pos.position;
- Rect_BiaoJi.position = placesItemPlacesWidget.Pos.position;
- }
- }
- }
- 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();
- }
- }
- }
|