| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- 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<PlacesInfoWidget> placesInfoWidgets = new List<PlacesInfoWidget>();
- private Action<bool> 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<bool> AsyncInit(object[] uiData)
- {
- PlacesId = (int)(uiData[0]);
- callBack = uiData[1] as Action<bool>;
- needSmallPlacesId = (int)(uiData[2]);
- isChange = false;
- placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(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<PlacesInfoWidget>(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<BigMapConfig>(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<bool> callBack, int needSmallPlacesId = 0)
- {
- await UIManager.Instance.LoadAndOpenPanel<PlacesInfoPanel>(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();
- }
- }
- }
|