public CreatureStateBody(string typeName, UnityEngine.GameObject parent) { creatureStateBodyPhysics = new CreatureStateBodyPhysics(); creatureStateBodyVisual = new CreatureStateBodyVisual(); var jsonNode = Bootstrap.GetDataStore().staticData.GetNode("creatures")[typeName]; //creatures if (null == jsonNode) { Bootstrap.Warn("creature not found:" + typeName, parent); return; } height = jsonNode["height"].AsFloat; //height = 0.5f; { var jsonBodyDataArray = jsonNode["body_data_array"]; if ((null != jsonBodyDataArray) && (true == jsonBodyDataArray.IsArray)) { for (int index = 0; index < jsonBodyDataArray.Count; ++index) { var bodyData = BodyData.Factory(jsonBodyDataArray[index]); bodyDataArray.Add(bodyData); _mapBodyRadius[bodyData.m_name] = bodyData.m_radius * 0.5f; } } } { var jsonSplineDataArray = jsonNode["spline_data_array"]; if ((null != jsonSplineDataArray) && (true == jsonSplineDataArray.IsArray)) { for (int index = 0; index < jsonSplineDataArray.Count; ++index) { splineDataArray.Add(SplineData.Factory(jsonSplineDataArray[index])); } } } { var jsonSphereDataArray = jsonNode["sphere_data_array"]; if ((null != jsonSphereDataArray) && (true == jsonSphereDataArray.IsArray)) { for (int index = 0; index < jsonSphereDataArray.Count; ++index) { sphereDataArray.Add(SphereData.Factory(jsonSphereDataArray[index])); } } } faceData = FaceData.Factory(jsonNode); }
public void Update() { creatureStateBodyVisual = new CreatureStateBodyVisual(); //update visual pos from physical foreach (var splineData in splineDataArray) { var p0 = MakePos(splineData.m_name[0]); var p1 = MakePos(splineData.m_name[1]); var p2 = MakePos(splineData.m_name[2]); creatureStateBodyVisual.splineRenderDataArray.Add(new CreatureStateBodyVisual.SplineRenderData() { color = splineData.m_color, p0 = p0, p1 = p1, p2 = p2 }); } foreach (var sphereData in sphereDataArray) { var p0 = MakePos(sphereData.m_name); creatureStateBodyVisual.sphereRenderDataArray.Add(new CreatureStateBodyVisual.SphereRenderData() { color = sphereData.m_color, p0 = p0 }); } { creatureStateBodyVisual.faceRenderData.color = faceData.m_color; creatureStateBodyVisual.faceRenderData.p0 = MakePos(faceData.m_name[0]); creatureStateBodyVisual.faceRenderData.p1 = MakePos(faceData.m_name[1]); creatureStateBodyVisual.faceRenderData.p2 = MakePos(faceData.m_name[2]); } }