Files
back_cantanBuilding/Assets/Scripts/UI/Shop/FishingShopSelectMapPopupPanel.cs
2026-05-26 16:15:54 +08:00

48 lines
1.5 KiB
C#

using asap.core;
using cfg;
using GameCore;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class FishingShopSelectMapPopupPanel : MonoBehaviour
{
#region Field
[SerializeField]
Transform
tran_mapParent;
[SerializeField]
GameObject
go_mapSlot;
[SerializeField]
Button
btn_confirm,
btn_close;
private int curMapID;
#endregion
#region Func
public void Init(int mapID)
{
curMapID = mapID;
go_mapSlot.SetActive(false);
var mapDatas = GContext.container.Resolve<Tables>().TbMapData.DataMap;
btn_close.onClick.AddListener(() => UIManager.Instance.DestroyUI(UITypes.FishingShopSelectMapPopupPanel));
int requireLevel = 0;
foreach ( var mapData in mapDatas.Values )
{
Instantiate(go_mapSlot, tran_mapParent).GetComponent<FishCardMapSelectSlot>().SetData(mapData, requireLevel);
requireLevel = mapData.LevelRequired;
}
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { MapData = mapDatas[curMapID] });
btn_confirm.onClick.AddListener(() => {
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { IsConfirm = true, MapData = mapDatas[curMapID] });
UIManager.Instance.DestroyUI(UITypes.FishingShopSelectMapPopupPanel);
});
GContext.OnEvent<FishCardShopSlot.SChangeFishCardMapEvent>().Where(x => !x.IsConfirm).Subscribe(x => curMapID = x.MapData.ID).AddTo(this);
}
#endregion
}