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 gradeMapItems = new List(); GradeMapItem selectMap; IDisposable disposable; private void Awake() { disposable = GContext.OnEvent().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().TbMapData.DataMap; int requireLevel = 0; foreach (var mapData in DataMap.Values) { GameObject go = Instantiate(item, content); GradeMapItem gradeMapItem = go.GetComponent(); gradeMapItems.Add(gradeMapItem); gradeMapItem.GetComponent().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; } }