PlacesInfoPanel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Core.Language;
  5. using Excel2Json;
  6. using Fort23.Core;
  7. using Fort23.UTool;
  8. using GameLogic.Combat;
  9. using GameLogic.Combat.CombatTool;
  10. using UnityEngine;
  11. namespace Fort23.Mono
  12. {
  13. [UIBinding(prefab = "PlacesInfoPanel")]
  14. public partial class PlacesInfoPanel : UIPanel
  15. {
  16. private int PlacesId;
  17. private int needSmallPlacesId;
  18. private SmallPlacesConfig smallPlacesConfig;
  19. private PlacesConfig placesConfig;
  20. List<PlacesInfoWidget> placesInfoWidgets = new List<PlacesInfoWidget>();
  21. private Action<bool> callBack;
  22. public bool isChange;
  23. private PlacesInfoWidget currentNeedPlacesInfoWidget;
  24. private void Init()
  25. {
  26. isPopUi = true;
  27. isAddStack = false;
  28. }
  29. protected override void AddEvent()
  30. {
  31. }
  32. protected override void DelEvent()
  33. {
  34. }
  35. public override void AddButtonEvent()
  36. {
  37. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  38. }
  39. public async override CTask<bool> AsyncInit(object[] uiData)
  40. {
  41. PlacesId = (int)(uiData[0]);
  42. callBack = uiData[1] as Action<bool>;
  43. needSmallPlacesId = (int)(uiData[2]);
  44. isChange = false;
  45. placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(PlacesId);
  46. foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds)
  47. {
  48. PlacesInfoWidget shopBtnWidget =
  49. await UIManager.Instance.CreateGComponent<PlacesInfoWidget>(null, Content);
  50. shopBtnWidget.CustomInit(placesConfigSmallPlacersId, callBack);
  51. if (needSmallPlacesId == shopBtnWidget.smallPlacesConfig.ID && shopBtnWidget.isUlock)
  52. {
  53. currentNeedPlacesInfoWidget = shopBtnWidget;
  54. }
  55. placesInfoWidgets.Add(shopBtnWidget);
  56. }
  57. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(placesConfig.bigMapID);
  58. Text_BigMapName.text = LanguageManager.Instance.Text(bigMapConfig.mapName);
  59. Text_PlacesName.text = LanguageManager.Instance.Text(placesConfig.placeName);
  60. AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(placesConfig.ID);
  61. int jindu = placesData == null ? 0 : placesData.progress;
  62. Text_PlacesComplteProgress.text =
  63. LanguageManager.Instance.Text(10378, (jindu / placesConfig.TotalScore * 100f).ToString("0"));
  64. return await base.AsyncInit(uiData);
  65. }
  66. public override CTask Show()
  67. {
  68. if (currentNeedPlacesInfoWidget != null)
  69. {
  70. Vector3 localPos = transform.InverseTransformPoint(currentNeedPlacesInfoWidget.transform.position);
  71. Vector2 size = currentNeedPlacesInfoWidget.transform.sizeDelta;
  72. GuideHand.transform.localPosition = PlayerGuideManager.Instance.GetProperPos(localPos, size,
  73. currentNeedPlacesInfoWidget.GObjectPoolInterface);
  74. }
  75. GuideHand.gameObject.SetActive(currentNeedPlacesInfoWidget != null);
  76. return base.Show();
  77. }
  78. public static async CTask OpenPanel(int placesId, Action<bool> callBack, int needSmallPlacesId = 0)
  79. {
  80. await UIManager.Instance.LoadAndOpenPanel<PlacesInfoPanel>(null, UILayer.Top,
  81. uiData: new object[] { placesId, callBack, needSmallPlacesId }, isShowBG: true);
  82. }
  83. public async override CTask Close()
  84. {
  85. foreach (var shopBtnWidget in placesInfoWidgets)
  86. {
  87. UIManager.Instance.DormancyGComponent(shopBtnWidget);
  88. }
  89. placesInfoWidgets.Clear();
  90. if (!isChange)
  91. {
  92. callBack?.Invoke(false);
  93. callBack = null;
  94. }
  95. currentNeedPlacesInfoWidget = null;
  96. await base.Close();
  97. }
  98. }
  99. }