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

62 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using UnityEngine;
using UniRx;
public class GetCurSelectMapEvent
{
public int type;//0获得当前选中的地图1更新当前选中的地图
public MapData selectMap;
}
public class PlayerGradeProgress : MonoBehaviour
{
GameObject item;
Transform content;
List<GradeMapItem> gradeMapItems = new List<GradeMapItem>();
GradeMapItem selectMap;
IDisposable disposable;
private void Awake()
{
disposable = GContext.OnEvent<GetCurSelectMapEvent>().Subscribe(GetCurSelectMap);
item = transform.Find("ScrollView/Viewport/Content/Item").gameObject;
content = transform.Find("ScrollView/Viewport/Content");
item.SetActive(false);
}
private void Start()
{
var DataMap = GContext.container.Resolve<Tables>().TbMapData.DataMap;
int requireLevel = 0;
foreach (var mapData in DataMap.Values)
{
GameObject go = Instantiate(item, content);
GradeMapItem gradeMapItem = go.GetComponent<GradeMapItem>();
gradeMapItems.Add(gradeMapItem);
gradeMapItem.GetComponent<GradeMapItem>().SetData(mapData, requireLevel, OnClickMap);
requireLevel = mapData.LevelRequired;
}
}
async void OnClickMap(GradeMapItem gradeMapItem)
{
selectMap = gradeMapItem;
await UIManager.Instance.ShowUI(UITypes.PlayerGradeAquariumPanel);
}
void GetCurSelectMap(GetCurSelectMapEvent getCurSelectMapEvent)
{
if (getCurSelectMapEvent.type == 0)
{
getCurSelectMapEvent.selectMap = selectMap.mapData;
}
else
{
selectMap.Refresh();
}
}
private void OnDestroy()
{
disposable?.Dispose();
disposable = null;
}
}