public static GreedleDirective FromJSON(JSON.Element rootElement) { var type = rootElement.jsonObject["type"].jsonString; switch (type) { case "target": return(new GreedleDirective() { type = DirectiveType.Target, targetDirective = new TargetDirective() { addressedTo = rootElement.jsonObject["addressedTo"].jsonString, target = Vector3Utils.Vector3FromJSON(rootElement.jsonObject["target"]), }, }); case "respond": return(new GreedleDirective() { type = DirectiveType.Respond, }); } throw new Exception("Unknown Directive Type"); }
public static GreedleResponse FromJSON(JSON.Element rootElement) { return(new GreedleResponse() { name = rootElement.jsonObject["name"].jsonString, position = Vector3Utils.Vector3FromJSON(rootElement.jsonObject["position"]) }); }
public static Location FromJSON(JSON.Element rootElement) { return(new Location() { name = rootElement.jsonObject["name"].jsonString, position = Vector3Utils.Vector3FromJSON(rootElement.jsonObject["position"]), pathsToLocations = rootElement.jsonObject["paths"].jsonObject .Select(element => new KeyValuePair <string, Waypath>(element.Key, Waypath.FromJSON(element.Value))) .ToDictionary(entry => entry.Key, entry => entry.Value) }); }
public static Waypoint FromJSON(JSON.Element rootElement) { string name = rootElement.jsonObject["name"].jsonString; float radius = (float)rootElement.jsonObject["radius"].jsonNumber; Vector3 position = Vector3Utils.Vector3FromJSON(rootElement.jsonObject["position"]); Vector3 direction = Vector3.Zero; JSON.Element directionElement; if (rootElement.jsonObject.TryGetValue("direction", out directionElement)) { direction = Vector3Utils.Vector3FromJSON(directionElement); } return(new Waypoint(name, radius, position, direction)); }