先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
150 lines
4.8 KiB
C#
150 lines
4.8 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using Game;
|
|
using GameCore;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
|
|
public class TravelMapCtrl
|
|
{
|
|
public TraveMapDataManager traveMapDataManager;
|
|
Tables tables;
|
|
GameObject _buildingObj;
|
|
TravelMapCampReveiwPanel travelMapCampReveiw;
|
|
int visitInidex = 0;
|
|
TraveMapItemData traveMapItemData;
|
|
public void Init(bool isVisit)
|
|
{
|
|
tables = GContext.container.Resolve<Tables>();
|
|
traveMapDataManager = new TraveMapDataManager();
|
|
traveMapDataManager.Init(isVisit);
|
|
}
|
|
|
|
public async void InBuildAct()
|
|
{
|
|
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
CampDataMM campData = GContext.container.Resolve<CampDataMM>();
|
|
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
|
|
if (isCanEnter)
|
|
{
|
|
InBuild();
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, InBuild);
|
|
}
|
|
}
|
|
|
|
async void InBuild()
|
|
{
|
|
GContext.Publish(new UnloadActToNextAct("BuildAct"));
|
|
await Awaiters.Seconds(0.5f);
|
|
OnDestroy();
|
|
}
|
|
|
|
public void OnLeft()
|
|
{
|
|
visitInidex--;
|
|
InVisit(visitInidex);
|
|
|
|
}
|
|
|
|
public void OnRight()
|
|
{
|
|
visitInidex++;
|
|
InVisit(visitInidex);
|
|
}
|
|
|
|
public async Task InVisit(int index)
|
|
{
|
|
visitInidex = index;
|
|
if (visitInidex < 0)
|
|
{
|
|
visitInidex = traveMapDataManager.mapShowItemData.Count - 1;
|
|
}
|
|
if (visitInidex >= traveMapDataManager.mapShowItemData.Count)
|
|
{
|
|
visitInidex = 0;
|
|
}
|
|
traveMapItemData = traveMapDataManager.mapShowItemData[visitInidex];
|
|
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
Construction mapData = tables.TbConstruction.Get(traveMapItemData.id);
|
|
string prefabName = GContext.container.Resolve<CampDataMM>().GetBasePrefab(traveMapItemData.id);
|
|
bool isCanEnter = await loadResourceService.Load(prefabName);
|
|
if (isCanEnter)
|
|
{
|
|
await InVisit(mapData);
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, async () => await InVisit(mapData));
|
|
}
|
|
}
|
|
|
|
async Task InVisit(Construction mapData)
|
|
{
|
|
await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
await Awaiters.Seconds(0.5f);
|
|
if (_buildingObj != null)
|
|
{
|
|
Addressables.ReleaseInstance(_buildingObj);
|
|
_buildingObj = null;
|
|
}
|
|
string prefabName = GContext.container.Resolve<CampDataMM>().GetBasePrefab(mapData.ID);
|
|
_buildingObj = await Addressables.InstantiateAsync(prefabName).Task;
|
|
GContext.Publish(new EventBGMSound(mapData.BGM));
|
|
GContext.Publish(new EndTransition());
|
|
if (_buildingObj == null)
|
|
{
|
|
Debug.LogError($"<color=red>TravelMapCtrl InVisit Error</color>");
|
|
return;
|
|
}
|
|
|
|
var buildComp = _buildingObj.GetComponentInChildren<Building>();
|
|
if (buildComp != null)
|
|
{
|
|
buildComp.SetTimelineAllDone();
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"<color=red>TravelMapCtrl InVisit Error</color>");
|
|
}
|
|
GContext.Publish(new SwitchVirtualCameraEvent() { type = 11, isDrag = true });
|
|
if (travelMapCampReveiw == null)
|
|
{
|
|
GameObject go = await UIManager.Instance.ShowUI(UITypes.TravelMapCampReveiwPanel);
|
|
travelMapCampReveiw = go.GetComponent<TravelMapCampReveiwPanel>();
|
|
UIManager.Instance.DestroyUI(UITypes.TravelMapPanel);
|
|
}
|
|
travelMapCampReveiw.SetName(traveMapItemData.name);
|
|
}
|
|
public async void OutVisit()
|
|
{
|
|
visitInidex = 0;
|
|
await UIManager.Instance.ShowUI(UITypes.TravelMapPanel);
|
|
GContext.Publish(new EventMainBGM());
|
|
UIManager.Instance.DestroyUI(UITypes.TravelMapCampReveiwPanel);
|
|
travelMapCampReveiw = null;
|
|
|
|
if (_buildingObj != null)
|
|
{
|
|
Addressables.ReleaseInstance(_buildingObj);
|
|
_buildingObj = null;
|
|
}
|
|
}
|
|
|
|
public void OnDestroy()
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.TravelMapPanel);
|
|
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
|
GContext.Publish(restartShowHomeUIEvent);
|
|
GContext.Publish(new MapShowEvent() { isShow = true });
|
|
traveMapDataManager = null;
|
|
GContext.container.Unregister<TravelMapCtrl>();
|
|
}
|
|
}
|