160 lines
4.4 KiB
C#
160 lines
4.4 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using Stary.Evo;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace Main
|
||
|
|
{
|
||
|
|
public interface IZoneData : IData
|
||
|
|
{
|
||
|
|
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()
|
||
|
|
{
|
||
|
|
_pointGatherData = Resources.Load<PointGatherData>("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()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|