PlacesInfoPanel.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Core.Language;
  2. using Excel2Json;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "PlacesInfoPanel")]
  8. public partial class PlacesInfoPanel : UIPanel
  9. {
  10. private int placesId;
  11. private void Init()
  12. {
  13. isPopUi = true;
  14. isAddStack = false;
  15. }
  16. protected override void AddEvent()
  17. {
  18. }
  19. protected override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. Btn_Go.onClick.AddListener(Click_Go);
  25. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  26. }
  27. public override CTask<bool> AsyncInit(object[] uiData)
  28. {
  29. placesId = (int)(uiData[0]);
  30. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(placesId);
  31. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(placesConfig.bigMapID);
  32. Text_BigMapName.text = LanguageManager.Instance.Text(bigMapConfig.mapName);
  33. Text_PlacesName.text = LanguageManager.Instance.Text(placesConfig.placeName);
  34. Text_PlacesComplteProgress.text = $"完成度:{PlayerManager.Instance.GetMapBl(placesId)}%";
  35. return base.AsyncInit(uiData);
  36. }
  37. private async void Click_Go()
  38. {
  39. if (placesId > 1 && PlayerManager.Instance.GetMapBl(placesId - 1) < 100)
  40. {
  41. TipMessagePanel.OpenTipMessagePanel("上一个关卡没有解锁");
  42. return;
  43. }
  44. AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(placesId);
  45. if (currentPlacesData == null)
  46. {
  47. currentPlacesData = new AccountFileInfo.PlacesData();
  48. currentPlacesData.id = placesId;
  49. AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData);
  50. }
  51. PlayerManager.Instance.CurrentPlaces = currentPlacesData;
  52. UIManager.Instance.HideUIUIPanel<LevelChoosePanel>();
  53. UIManager.Instance.HideUIUIPanel(this);
  54. EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
  55. }
  56. public static async CTask OpenPanel(int placesId)
  57. {
  58. await UIManager.Instance.LoadAndOpenPanel<PlacesInfoPanel>(null, UILayer.Top, uiData: new object[] { placesId });
  59. }
  60. }
  61. }