备份CatanBuilding瘦身独立工程
This commit is contained in:
61
Assets/Scripts/UI/Grade/PlayerGradeProgress.cs
Normal file
61
Assets/Scripts/UI/Grade/PlayerGradeProgress.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user