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; 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); foreach (var placesConfigSmallPlacersId in placesConfig.SmallPlacersIds) { PlacesInfoWidget shopBtnWidget = await UIManager.Instance.CreateGComponent(null, Content); shopBtnWidget.CustomInit(placesConfigSmallPlacersId, callBack); if (needSmallPlacesId == shopBtnWidget.smallPlacesConfig.ID && shopBtnWidget.isUlock) { currentNeedPlacesInfoWidget = shopBtnWidget; } 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 override CTask Show() { if (currentNeedPlacesInfoWidget != null) { Vector3 localPos = transform.InverseTransformPoint(currentNeedPlacesInfoWidget.transform.position); Vector2 size = currentNeedPlacesInfoWidget.transform.sizeDelta; GuideHand.transform.localPosition = PlayerGuideManager.Instance.GetProperPos(localPos, size, currentNeedPlacesInfoWidget.GObjectPoolInterface); } GuideHand.gameObject.SetActive(currentNeedPlacesInfoWidget != null); return base.Show(); } 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(); } } }