123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System.Collections.Generic;
- 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<ShopBtnWidget> _shopBtnWidgets = new List<ShopBtnWidget>();
- 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<bool> AsyncInit(object[] uiData)
- {
- PlacesId = (int)(uiData[0]);
- // smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(PlacesId);
- placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(PlacesId);
- foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds)
- {
- ShopBtnWidget shopBtnWidget = await UIManager.Instance.CreateGComponent<ShopBtnWidget>(null, Content);
- shopBtnWidget.CustomInit(placesConfigSmallPlacersId);
- shopBtnWidget.OnClick = OnClick;
- _shopBtnWidgets.Add(shopBtnWidget);
- }
- toggleList.GetChildObj();
- _shopBtnWidgets[0].OnPointerClick();
- BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(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>(smallPlacesConfig.ID - 1);
- if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null || lastSmallPlacesData.completionEventCount < lastSmallPlacesConfig.CompletionEventCount))
- {
- TipMessagePanel.OpenTipMessagePanel("上一个关卡事件完成度不足");
- return;
- }
- AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.PlacesId);
- 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<LevelChoosePanel>();
- UIManager.Instance.HideUIUIPanel(this);
- EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
- }
- public static async CTask OpenPanel(int placesId)
- {
- await UIManager.Instance.LoadAndOpenPanel<PlacesInfoPanel>(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();
- }
- }
- }
|