private TerrainObject ParseTerrainObject(JObject currentGameObject, GameObject parent = null) { var name = JSONHelper.GetValue("Name", currentGameObject); var model = JSONHelper.GetValue("Model", currentGameObject); var IsEnabled = JSONHelper.ToBool(JSONHelper.GetValue("isEnabled", currentGameObject)); var mod = ToylandSiege.GetInstance().Content.Load <Model>(model); var terrainObj = new TerrainObject(name, mod); terrainObj.IsEnabled = IsEnabled; terrainObj.IsStatic = true; terrainObj.IsCollidable = true; terrainObj.Type = JSONHelper.GetValue("Type", currentGameObject); terrainObj.Parent = parent; if (JSONHelper.ValueExist("Position", currentGameObject)) { terrainObj.Position = JSONHelper.ParseVector3(currentGameObject.GetValue("Position")); } if (JSONHelper.ValueExist("Rotation", currentGameObject)) { terrainObj.Rotation = JSONHelper.ParseVector3(currentGameObject.GetValue("Rotation")); } if (JSONHelper.ValueExist("Scale", currentGameObject)) { terrainObj.Scale = JSONHelper.ParseVector3(currentGameObject.GetValue("Scale")); } terrainObj.CreateTransformationMatrix(); if (JSONHelper.ValueExist("Child", currentGameObject)) { for (int i = 0; i < currentGameObject.GetValue("Child").Count(); i++) { terrainObj.AddChild(ParseGameObject(currentGameObject.GetValue("Child")[i].ToObject <JObject>(), terrainObj)); } } // TODO: Load from a config file? terrainObj.Collider.BType = Collider.BoundingType.Box; terrainObj.Collider.RecreateBounding(); return(terrainObj); }