Commit 2f1e5df6 authored by 杨泽宇's avatar 杨泽宇

更新AGV

parent eb01de77
......@@ -7,37 +7,55 @@ using System.Linq;
public class CloudiaMapDecoderV2 : CloudiaMapDecoder
{
public new TextAsset DataFile;
public override List<DTMapTargetPosition> DecodeMapKeyPositionInfo()
{
JsonData nodes = JsonMapper.ToObject(DataFile.text);
JsonData data = JsonMapper.ToObject(DataFile.text);
JsonData advancedPointLists = data["advancedPointList"];
List<DTMapTargetPosition> result = new List<DTMapTargetPosition>();
foreach (JsonData node in nodes)
foreach (JsonData advancedPointList in advancedPointLists)
{
DTMapTargetPosition p = (new GameObject()).AddComponent<DTMapTargetPosition>();
p.name = node["instanceName"].ToString();
p.name = advancedPointList["instanceName"].ToString();
float x = 0f;
float y = 0f;
// 如果JSON数据中的坐标是整数类型,则将其转换为float
if (node["pos"]["x"].IsInt)
x = (float)(int)node["pos"]["x"];
else if (node["pos"]["x"].IsDouble)
x = (float)(double)node["pos"]["x"];
if (advancedPointList["pos"]["x"].IsInt)
x = (float)(int)advancedPointList["pos"]["x"];
else if (advancedPointList["pos"]["x"].IsDouble)
x = (float)(double)advancedPointList["pos"]["x"];
if (node["pos"]["y"].IsInt)
y = (float)(int)node["pos"]["y"];
else if (node["pos"]["y"].IsDouble)
y = (float)(double)node["pos"]["y"];
if (advancedPointList["pos"]["y"].IsInt)
y = (float)(int)advancedPointList["pos"]["y"];
else if (advancedPointList["pos"]["y"].IsDouble)
y = (float)(double)advancedPointList["pos"]["y"];
p.RealPosition = new Vector3(x, y, 0);
result.Add(p);
}
if (data.ContainsKey("advancedCurveList"))
{
JsonData advancedCurveLists = data["advancedCurveList"];
foreach (JsonData advancedCurveList in advancedCurveLists)
{
string instanceName = advancedCurveList["instanceName"].ToString();
string[] instanceNames = instanceName.Split("-");
string srcInstanceName = instanceNames[0];
string dstInstanceName = instanceNames[1];
var s_objs = (from x in result where x.name == srcInstanceName select x).ToArray();
var d_objs = (from x in result where x.name == dstInstanceName select x).ToArray();
if (s_objs.Length > 0 && d_objs.Length > 0)
{
s_objs[0].NextPositions.Add(d_objs[0]);
}
}
}
return result;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment