报错修改
This commit is contained in:
170
Assets/Domain/Main/HotUpdate/ZoneGatherData.cs
Normal file
170
Assets/Domain/Main/HotUpdate/ZoneGatherData.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public interface IZoneData : IData
|
||||
{
|
||||
UniTask Load();
|
||||
ZoneData[] GetZoneDataAll();
|
||||
ZoneData GetZoneData(int id);
|
||||
ZoneData GetZoneData(string domain);
|
||||
PointData GetPointData(int zoneId, int pointId);
|
||||
PointData GetPointData(string zoneDomain, string pointDomain);
|
||||
}
|
||||
|
||||
|
||||
public class ZoneGatherData : AbstractData, IZoneData
|
||||
{
|
||||
private PointGatherData _pointGatherData;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async UniTask Load()
|
||||
{
|
||||
var package = YooAssets.GetPackage("Main");
|
||||
var handle = package.LoadAssetAsync<PointGatherData>(R.Res.Main.config.pointgatherdata_asset);
|
||||
await handle.Task;
|
||||
_pointGatherData = handle.GetAssetObject<PointGatherData>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过id获取区域数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public ZoneData[] GetZoneDataAll()
|
||||
{
|
||||
if (_pointGatherData != null)
|
||||
{
|
||||
for (int i = 0; i < _pointGatherData.ZoneDatas.Count; i++)
|
||||
{
|
||||
|
||||
return _pointGatherData.ZoneDatas.ToArray();
|
||||
|
||||
}
|
||||
|
||||
Debug.LogWarning($"UnityEvo:PointGatherData is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:PointGatherData is null");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过id获取区域数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public ZoneData GetZoneData(int id)
|
||||
{
|
||||
if (_pointGatherData != null)
|
||||
{
|
||||
for (int i = 0; i < _pointGatherData.ZoneDatas.Count; i++)
|
||||
{
|
||||
if (_pointGatherData.ZoneDatas[i].id == id)
|
||||
{
|
||||
return _pointGatherData.ZoneDatas[i];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning($"UnityEvo:{id}在PointGatherData is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:PointGatherData is null");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过id获取区域数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public ZoneData GetZoneData(string domain)
|
||||
{
|
||||
if (_pointGatherData != null)
|
||||
{
|
||||
for (int i = 0; i < _pointGatherData.ZoneDatas.Count; i++)
|
||||
{
|
||||
if (_pointGatherData.ZoneDatas[i].name == domain)
|
||||
{
|
||||
return _pointGatherData.ZoneDatas[i];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning($"UnityEvo:{domain}在PointGatherData is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:PointGatherData is null");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public PointData GetPointData(int zoneId, int pointId)
|
||||
{
|
||||
ZoneData zoneData = GetZoneData(zoneId);
|
||||
if (zoneData.pointDatas != null)
|
||||
{
|
||||
for (int i = 0; i < zoneData.pointDatas.Count; i++)
|
||||
{
|
||||
if (zoneData.pointDatas[i].id == pointId)
|
||||
{
|
||||
return zoneData.pointDatas[i];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning($"UnityEvo:{pointId}在PointGatherData.zoneData.pointDatas is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:PointGatherData.zoneData.pointDatas is null");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public PointData GetPointData(string zoneDomain, string pointDomain)
|
||||
{
|
||||
ZoneData zoneData = GetZoneData(zoneDomain);
|
||||
if (zoneData.pointDatas != null)
|
||||
{
|
||||
for (int i = 0; i < zoneData.pointDatas.Count; i++)
|
||||
{
|
||||
if (zoneData.pointDatas[i].name == pointDomain)
|
||||
{
|
||||
return zoneData.pointDatas[i];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning($"UnityEvo:{pointDomain}在PointGatherData.zoneData.pointDatas is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:PointGatherData.zoneData.pointDatas is null");
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user