using System; using System.Collections.Generic; using System.Linq; using Core.Language; using Excel2Json; using Fort23.Core; using Fort23.UTool; using GameLogic.Combat; using GameLogic.Combat.CombatTool; using UnityEngine; using UnityEngine.UI; namespace Fort23.Mono { [UIBinding(prefab = "PlacesInfoPanel")] public partial class PlacesInfoPanel : UIPanel { private int PlacesId; private int needSmallPlacesId; private SmallPlacesConfig smallPlacesConfig; private PlacesConfig placesConfig; List placesInfoWidgets = new List(); private Action callBack; public bool isChange; private PlacesInfoWidget currentNeedPlacesInfoWidget; private void Init() { isPopUi = true; isAddStack = false; } protected override void AddEvent() { } protected override void DelEvent() { } public override void AddButtonEvent() { Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); }); } public async override CTask AsyncInit(object[] uiData) { PlacesId = (int)(uiData[0]); callBack = uiData[1] as Action; needSmallPlacesId = (int)(uiData[2]); isChange = false; placesConfig = ConfigComponent.Instance.Get(PlacesId); sv.vertical = true; int maxY = 131 * placesConfig.SmallPlacersIds.Length + (placesConfig.SmallPlacersIds.Length) * 33; Content.sizeDelta = new Vector2(551, maxY); for (var i = 0; i < placesConfig.SmallPlacersIds.Length; i++) { PlacesInfoWidget shopBtnWidget = await UIManager.Instance.CreateGComponent(null, Content); shopBtnWidget.CustomInit(placesConfig.SmallPlacersIds[i], callBack); shopBtnWidget.transform.anchoredPosition = new Vector2(0, -131 * i - 33 * i); if (needSmallPlacesId == shopBtnWidget.smallPlacesConfig.ID && shopBtnWidget.isUlock) { currentNeedPlacesInfoWidget = shopBtnWidget; int y = 131 * (i - 1) + 33 * (i - 1); if (y < 0) { y = 0; } else if (y >= maxY) { y = maxY; } Content.anchoredPosition = new Vector2(0, y); sv.vertical = false; } placesInfoWidgets.Add(shopBtnWidget); } BigMapConfig bigMapConfig = ConfigComponent.Instance.Get(placesConfig.bigMapID); Text_BigMapName.text = LanguageManager.Instance.Text(bigMapConfig.mapName); Text_PlacesName.text = LanguageManager.Instance.Text(placesConfig.placeName); AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(placesConfig.ID); int jindu = placesData == null ? 0 : placesData.progress; Text_PlacesComplteProgress.text = LanguageManager.Instance.Text(10378, (jindu / placesConfig.TotalScore * 100f).ToString("0")); return await base.AsyncInit(uiData); } public async override CTask Show() { base.Show(); // LayoutRebuilder.ForceRebuildLayoutImmediate(Content); GuideHand.gameObject.SetActive(currentNeedPlacesInfoWidget != null); } [CustomMethod(CustomMethodType.Update)] public void Update() { if (currentNeedPlacesInfoWidget != null) { if (currentNeedPlacesInfoWidget.currentSmallPlacesData == null && currentNeedPlacesInfoWidget.IsSmallPlacesDataUlock(currentNeedPlacesInfoWidget.smallPlacesConfig .ID)) { Vector3 localPos = transform.InverseTransformPoint(currentNeedPlacesInfoWidget.Btn_Jiesuo.transform.position); GuideHand.transform.localPosition = localPos; } else { Vector3 localPos = transform.InverseTransformPoint( currentNeedPlacesInfoWidget.Btn_Qianwang.transform.position); GuideHand.transform.localPosition = localPos; } } } public static async CTask OpenPanel(int placesId, Action callBack, int needSmallPlacesId = 0) { await UIManager.Instance.LoadAndOpenPanel(null, UILayer.Top, uiData: new object[] { placesId, callBack, needSmallPlacesId }, isShowBG: true); } public async override CTask Close() { foreach (var shopBtnWidget in placesInfoWidgets) { UIManager.Instance.DormancyGComponent(shopBtnWidget); } placesInfoWidgets.Clear(); if (!isChange) { callBack?.Invoke(false); callBack = null; } currentNeedPlacesInfoWidget = null; await base.Close(); } } }