|
@@ -48,27 +48,30 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
- private void AnalysisJson( string message )
|
|
|
+ private void AnalysisJson(string message)
|
|
|
{
|
|
|
if (!state)
|
|
|
- return;
|
|
|
+ return;
|
|
|
Debug.Log("Message aaa " + message);
|
|
|
- if(message == ""||message == "Message")
|
|
|
+ if (message == "" || message == "Message")
|
|
|
{
|
|
|
Debug.LogError("未接受到json 数据");
|
|
|
udpClient.SendIpToBluetooth();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if(!isInit)
|
|
|
- return;
|
|
|
-
|
|
|
- isInit = false;
|
|
|
|
|
|
- data = JsonControl.Instance().ToJsonData(message);
|
|
|
-
|
|
|
+ data = JsonControl.Instance.ToJsonData(message);
|
|
|
+
|
|
|
if (data == null)
|
|
|
+ {
|
|
|
+ udpClient.SendIpToBluetooth();
|
|
|
return;
|
|
|
+ }
|
|
|
+ if (!isInit)
|
|
|
+ return;
|
|
|
+ state = false;
|
|
|
+ isInit = false;
|
|
|
|
|
|
for (int i = 0; i < data.navLines.Count; i++)
|
|
|
{
|
|
@@ -87,11 +90,11 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
- private void SettingLuJing( Root data)
|
|
|
+ private void SettingLuJing(Root data)
|
|
|
{
|
|
|
for (int i = 0; i < data.navLines.Count; i++)
|
|
|
{
|
|
|
- for (int j = 0; j < data.navLines[i].points.Count-1; j++)
|
|
|
+ for (int j = 0; j < data.navLines[i].points.Count - 1; j++)
|
|
|
{
|
|
|
GameObject route = GameObject.Instantiate(meshRoute, meshRoute.transform.parent);
|
|
|
Vector3 endPos = new Vector3((float)data.navLines[i].points[j].X, 0, (float)data.navLines[i].points[j].Y);
|
|
@@ -105,24 +108,24 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void SettingLuJing(NavLinesItem data , int Index)
|
|
|
+ private void SettingLuJing(NavLinesItem data, int Index)
|
|
|
{
|
|
|
GameObject routes = new GameObject("Route" + Index.ToString());
|
|
|
routes.transform.parent = meshRoute.transform.parent;
|
|
|
for (int j = 0; j < data.points.Count - 1; j++)
|
|
|
- {
|
|
|
- GameObject route = GameObject.Instantiate(meshRoute, routes.transform);
|
|
|
- Vector3 endPos = new Vector3((float)data.points[j].X, 0, (float)data.points[j].Y);
|
|
|
- Vector3 exitPos = new Vector3((float)data.points[j + 1].X, 0, (float)data.points[j + 1].Y);
|
|
|
- Debug.Log(endPos + " " + exitPos);
|
|
|
- route.GetComponent<TestRoute>().SetRoute(endPos, exitPos , Index);
|
|
|
- route.SetActive(true);
|
|
|
+ {
|
|
|
+ GameObject route = GameObject.Instantiate(meshRoute, routes.transform);
|
|
|
+ Vector3 endPos = new Vector3((float)data.points[j].X, 0, (float)data.points[j].Y);
|
|
|
+ Vector3 exitPos = new Vector3((float)data.points[j + 1].X, 0, (float)data.points[j + 1].Y);
|
|
|
+ Debug.Log(endPos + " " + exitPos);
|
|
|
+ route.GetComponent<TestRoute>().SetRoute(endPos, exitPos, Index);
|
|
|
+ route.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
teshMap.ADDMapRoutePoint(endPos);
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
teshMap.ADDMapRoutePoint(new Vector3((float)data.points[data.points.Count - 1].X, 0, (float)data.points[data.points.Count - 1].Y));
|
|
|
teshMap.SettingMapRoute();
|
|
|
|
|
@@ -130,7 +133,7 @@ public class TestJsonManage : MonoBehaviour
|
|
|
}
|
|
|
public void SettingLuJing(int Index)
|
|
|
{
|
|
|
- if(list_route ==null||list_route.Count<Index)
|
|
|
+ if (list_route == null || list_route.Count < Index)
|
|
|
{
|
|
|
Debug.LogError(" 未初始化路径 或 所选的路径不存在 ");
|
|
|
return;
|
|
@@ -146,12 +149,12 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
private void Update()
|
|
|
{
|
|
|
- if(state && UdpClient.logMBSRD!=null)
|
|
|
+ if (state && UdpClient.logMBSRD != null)
|
|
|
{
|
|
|
Debug.Log(" UdpClient.logMBSRD");
|
|
|
UdpClient.logMBSRD(result);
|
|
|
- UdpClient.logMBSRD -= AnalysisJson;
|
|
|
- state = false;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -171,7 +174,7 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
- private void SettingObj( Root data)
|
|
|
+ private void SettingObj(Root data)
|
|
|
{
|
|
|
for (int i = 0; i < data.navLines.Count; i++)
|
|
|
{
|
|
@@ -182,7 +185,7 @@ public class TestJsonManage : MonoBehaviour
|
|
|
switch (data.navLines[i].points[j].MN)
|
|
|
{
|
|
|
case "Transformers":
|
|
|
- QueryBox("P6", data.navLines[i].points[j]);
|
|
|
+ QueryBox("P6", data.navLines[i].points[j]);
|
|
|
break;
|
|
|
case "Car":
|
|
|
QueryBox("P4Car", data.navLines[i].points[j]);
|
|
@@ -213,7 +216,7 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
|
|
|
private void QueryBox(string Name, PointsItem points)
|
|
|
- {
|
|
|
+ {
|
|
|
for (int i = 0; i < list_Obj.Count; i++)
|
|
|
{
|
|
|
if (list_Obj[i].name == Name)
|
|
@@ -225,7 +228,7 @@ public class TestJsonManage : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -233,33 +236,33 @@ public class TestJsonManage : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
- private void SettingBox( Transform box , Transform obj, Transform crystal, PointsItem points )
|
|
|
+ private void SettingBox(Transform box, Transform obj, Transform crystal, PointsItem points)
|
|
|
{
|
|
|
- box.position = new Vector3((float)points.X, -1f, (float)points.Y);
|
|
|
+ box.position = new Vector3((float)points.X, -1f, (float)points.Y);
|
|
|
crystal.position = new Vector3(box.position.x, -3f, box.position.z);
|
|
|
- obj.position = new Vector3((float)points.MP[0].X, points.MP[0].Z==-1?obj.position.y:(float)points.MP[0].Z, (float)points.MP[0].Y);
|
|
|
-
|
|
|
+ obj.position = new Vector3((float)points.MP[0].X, points.MP[0].Z == -1 ? obj.position.y : (float)points.MP[0].Z, (float)points.MP[0].Y);
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void SettingBox(Transform obj, MPItem mpItem)
|
|
|
{
|
|
|
- obj.position = new Vector3((float)mpItem.X,mpItem.Z==-1?obj.position.y: (float)mpItem.Z, (float)mpItem.Y);
|
|
|
-
|
|
|
+ obj.position = new Vector3((float)mpItem.X, mpItem.Z == -1 ? obj.position.y : (float)mpItem.Z, (float)mpItem.Y);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void SettingBox(Transform obj, Vector3 mpItem)
|
|
|
{
|
|
|
Debug.Log(obj.name);
|
|
|
- obj.position = new Vector3((float)mpItem.x, obj.position.y, (float)mpItem.y);
|
|
|
+ obj.position = new Vector3((float)mpItem.x, obj.position.y, (float)mpItem.y);
|
|
|
list_Crystal[0].position = new Vector3(obj.position.x, -2.5f, obj.position.z);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
IEnumerator Test()
|
|
|
{
|
|
|
WWW www = new WWW(Application.streamingAssetsPath + "/projectInfo.json");
|
|
|
yield return www;
|
|
|
- string message = www.text;
|
|
|
+ string message = www.text;
|
|
|
Debug.Log(message);
|
|
|
AnalysisJson(message);
|
|
|
}
|