Files
2026-05-26 16:15:54 +08:00

73 lines
2.4 KiB
C#

using asap.core;
using game;
using UnityEngine;
using UnityEngine.UI;
public class TravelMapPanel : BasePanel
{
Button btn_close;
GameObject tips_noopen;
Transform item_wenli;
TraveMapScrollViewController tvc;
TraveMapDataManager mapDataManager;
TravelMapCtrl travelMapCtrl;
private void Awake()
{
Input.multiTouchEnabled = false;
travelMapCtrl = GContext.container.Resolve<TravelMapCtrl>();
mapDataManager = travelMapCtrl.traveMapDataManager;
tips_noopen = transform.Find("root/tips_noopen").gameObject;
tvc = transform.Find("root/ScrollView_map").GetComponent<TraveMapScrollViewController>();
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
item_wenli = transform.Find("root/item_wenli");
}
protected override void Start()
{
tips_noopen.SetActive(false);
tvc.Init(tips_noopen, tvc, travelMapCtrl);
//tvc.cellViewVisibilityChanged = CellViewVisibilityChanged;
//tvc.cellViewWillRecycle = CellViewWillRecycle;
tvc.JumpToDataIndex(mapDataManager.index);
GetOperationItem();
//item_wenli.SetParent(tvc.Container, false);
//item_wenli.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0);
//item_wenli.SetAsFirstSibling();
btn_close.onClick.AddListener(OnClose);
}
private void Update()
{
if (tvc != null && item_wenli != null)
{
item_wenli.position = tvc.Container.position;
}
//UpdateActionChain();
}
public async void GetOperationItem()
{
if (mapDataManager.IsVisit)
{
//如果已经访问过了
return;
}
if (tvc == null) return;
TraveMapItem traveMapItem = tvc.GetCurrentItem();
if (traveMapItem == null) return;
traveMapItem.PlayAni();
btn_close.gameObject.SetActive(false);
await Awaiters.Seconds(3);
GContext.Publish(new UnloadActToNextAct());
await Awaiters.Seconds(0.5f);
OnClose();
}
private void OnClose()
{
//RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
//GContext.Publish(restartShowHomeUIEvent);
//GContext.Publish(new MapShowEvent() { isShow = true });
//关闭当前面板
travelMapCtrl.OnDestroy();
}
}