PlacesInfoPanel.cs 4.0 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. using UnityEngine.UI;
  12. namespace Fort23.Mono
  13. {
  14. [UIBinding(prefab = "PlacesInfoPanel")]
  15. public partial class PlacesInfoPanel : UIPanel
  16. {
  17. private int PlacesId;
  18. private int needSmallPlacesId;
  19. private SmallPlacesConfig smallPlacesConfig;
  20. private PlacesConfig placesConfig;
  21. List<PlacesInfoWidget> placesInfoWidgets = new List<PlacesInfoWidget>();
  22. private Action<bool> callBack;
  23. public bool isChange;
  24. private PlacesInfoWidget currentNeedPlacesInfoWidget;
  25. private void Init()
  26. {
  27. isPopUi = true;
  28. isAddStack = false;
  29. }
  30. protected override void AddEvent()
  31. {
  32. }
  33. protected override void DelEvent()
  34. {
  35. }
  36. public override void AddButtonEvent()
  37. {
  38. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  39. }
  40. public async override CTask<bool> AsyncInit(object[] uiData)
  41. {
  42. PlacesId = (int)(uiData[0]);
  43. callBack = uiData[1] as Action<bool>;
  44. needSmallPlacesId = (int)(uiData[2]);
  45. isChange = false;
  46. placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(PlacesId);
  47. foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds)
  48. {
  49. PlacesInfoWidget shopBtnWidget =
  50. await UIManager.Instance.CreateGComponent<PlacesInfoWidget>(null, Content);
  51. shopBtnWidget.CustomInit(placesConfigSmallPlacersId, callBack);
  52. if (needSmallPlacesId == shopBtnWidget.smallPlacesConfig.ID && shopBtnWidget.isUlock)
  53. {
  54. currentNeedPlacesInfoWidget = shopBtnWidget;
  55. }
  56. placesInfoWidgets.Add(shopBtnWidget);
  57. }
  58. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(placesConfig.bigMapID);
  59. Text_BigMapName.text = LanguageManager.Instance.Text(bigMapConfig.mapName);
  60. Text_PlacesName.text = LanguageManager.Instance.Text(placesConfig.placeName);
  61. AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(placesConfig.ID);
  62. int jindu = placesData == null ? 0 : placesData.progress;
  63. Text_PlacesComplteProgress.text =
  64. LanguageManager.Instance.Text(10378, (jindu / placesConfig.TotalScore * 100f).ToString("0"));
  65. return await base.AsyncInit(uiData);
  66. }
  67. public async override CTask Show()
  68. {
  69. base.Show();
  70. LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
  71. if (currentNeedPlacesInfoWidget != null)
  72. {
  73. Vector3 localPos = transform.InverseTransformPoint(currentNeedPlacesInfoWidget.transform.position);
  74. GuideHand.transform.localPosition = localPos;
  75. }
  76. GuideHand.gameObject.SetActive(currentNeedPlacesInfoWidget != null);
  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. }