// // Parse JSON data // public void parseJson(JSONNode data) { id = 0; if (data ["id"] != null) { id = Int32.Parse(data ["id"]); } /*name = ""; * if (data ["n"] != null) { * name = data ["n"]; * }*/ position = new DataTypeVector3(); position.x = 0; position.y = 0; position.z = 0; if (data ["p"] != null) { if (data ["p"] ["x"] != null) { position.x = (float)data ["p"] ["x"]; } if (data ["p"] ["y"] != null) { position.y = (float)data ["p"] ["y"]; } if (data ["p"] ["z"] != null) { position.z = (float)data ["p"] ["z"]; } } rotation = new DataTypeQuaternion(); rotation.w = 0; rotation.x = 0; rotation.y = 0; rotation.z = 0; if (data ["r"] != null) { if (data ["r"] ["w"] != null) { rotation.w = (float)data ["r"] ["w"]; } if (data ["r"] ["x"] != null) { rotation.x = (float)data ["r"] ["x"]; } if (data ["r"] ["y"] != null) { rotation.y = (float)data ["r"] ["y"]; } if (data ["r"] ["z"] != null) { rotation.z = (float)data ["r"] ["z"]; } } }
// // Parse JSON data // public void parseJson(JSONNode data) { int i, len; LevelObject levelObject; /*name = ""; * if (data ["n"] != null) { * name = data ["n"]; * }*/ position = new DataTypeVector3(); position.x = 0; position.y = 0; position.z = 0; if (data ["p"] != null) { if (data ["p"] ["x"] != null) { position.x = (float)data ["p"] ["x"]; } if (data ["p"] ["y"] != null) { position.y = (float)data ["p"] ["y"]; } if (data ["p"] ["z"] != null) { position.z = (float)data ["p"] ["z"]; } } /*isEdge = 0; * if (data ["e"] != null) { * isEdge = Int32.Parse (data ["e"]); * }*/ levelObjects = new List <LevelObject> (); if (data ["objs"] != null) { JSONArray objs = (JSONArray)data ["objs"]; if (objs != null) { len = objs.Count; for (i = 0; i < len; ++i) { levelObject = new LevelObject(); levelObject.parseJson(objs [i]); levelObjects.Add(levelObject); } } } }
// // Parse JSON data // public void parseJson(JSONNode data) { position = new DataTypeVector3(); position.x = 0; position.y = 0; position.z = 0; if (data ["p"] != null) { if (data ["p"] ["x"] != null) { position.x = (float)data ["p"] ["x"]; } if (data ["p"] ["y"] != null) { position.y = (float)data ["p"] ["y"]; } if (data ["p"] ["z"] != null) { position.z = (float)data ["p"] ["z"]; } } size = new DataTypeVector3(); size.x = 0; size.y = 0; size.z = 0; if (data ["s"] != null) { if (data ["s"] ["x"] != null) { size.x = (float)data ["s"] ["x"]; } if (data ["s"] ["y"] != null) { size.y = (float)data ["s"] ["y"]; } if (data ["s"] ["z"] != null) { size.z = (float)data ["s"] ["z"]; } } materialId = 0; if (data ["m"] != null) { materialId = Int32.Parse(data ["m"]); } }
public static DataTypeVector3[] vector3ToDataTypeVector3(Vector3[] v3Array) { //Debug.Log ("vector3ToDataTypeVector3"); int len = v3Array.Length; DataTypeVector3[] dtv3Array = new DataTypeVector3[len]; for (int i = 0; i < len; ++i) { //Debug.Log (" ->"+i); DataTypeVector3 dtv3 = new DataTypeVector3(); dtv3.x = v3Array [i].x; dtv3.y = v3Array [i].y; dtv3.z = v3Array [i].z; dtv3Array [i] = dtv3; //Debug.Log (" ->"+v3Array [i].ToString() + " to " + +dtv3Array[i].x+", "+dtv3Array[i].y+", "+dtv3Array[i].z); } return(dtv3Array); }
// // Parse JSON data // public void parseJson(string json) { int i, len; LevelQuadrant levelQuadrant; LevelProp levelProp; //Debug.Log (json); JSONNode data = JSON.Parse(json); fileFormatVersion = -1; if (data ["v"] != null) { fileFormatVersion = Int32.Parse(data ["v"]); } levelId = -1; if (data ["id"] != null) { levelId = Int32.Parse(data ["id"]); } levelPos = new DataTypeVector3(); if (data ["pos"] != null) { if (data ["pos"] ["x"] != null) { levelPos.x = (float)data ["pos"] ["x"]; } if (data ["pos"] ["y"] != null) { levelPos.y = (float)data ["pos"] ["y"]; } if (data ["pos"] ["z"] != null) { levelPos.z = (float)data ["pos"] ["z"]; } } levelName = ""; if (data ["n"] != null) { levelName = data ["n"]; } levelQuadrants = new List <LevelQuadrant> (); if (data ["quads"] != null) { JSONArray quads = (JSONArray)data ["quads"]; if (quads != null) { len = quads.Count; for (i = 0; i < len; ++i) { levelQuadrant = new LevelQuadrant(); levelQuadrant.parseJson(quads [i]); levelQuadrants.Add(levelQuadrant); } } } levelProps = new List <LevelProp> (); if (data ["props"] != null) { JSONArray props = (JSONArray)data ["props"]; if (props != null) { len = props.Count; for (i = 0; i < len; ++i) { levelProp = new LevelProp(); levelProp.parseJson(props [i]); levelProps.Add(levelProp); } } } playerPosition = new DataTypeVector3(); playerPosition.x = 0; playerPosition.y = 0; playerPosition.z = 0; if (data ["p"] != null) { if (data ["p"] ["x"] != null) { playerPosition.x = (float)data ["p"] ["x"]; } if (data ["p"] ["y"] != null) { playerPosition.y = (float)data ["p"] ["y"]; } if (data ["p"] ["z"] != null) { playerPosition.z = (float)data ["p"] ["z"]; } } playerEuler = new DataTypeVector3(); playerEuler.x = 0; playerEuler.y = 0; playerEuler.z = 0; if (data ["r"] != null) { if (data ["r"] ["x"] != null) { playerEuler.x = (float)data ["r"] ["x"]; } if (data ["r"] ["y"] != null) { playerEuler.y = (float)data ["r"] ["y"]; } if (data ["r"] ["z"] != null) { playerEuler.z = (float)data ["r"] ["z"]; } } }