public static JSON.Element ToJSON(GreedleResponse response)
 {
     return(JSON.Element.NewObject(new Dictionary <string, JSON.Element>()
     {
         ["name"] = JSON.Element.NewString(response.name),
         ["position"] = Vector3Utils.Vector3ToJSON(response.position),
     }));
 }
Beispiel #2
0
 public static JSON.Element ToJSON(Waypoint point)
 {
     return(JSON.Element.NewObject(new Dictionary <string, JSON.Element>()
     {
         ["name"] = JSON.Element.NewString(point.name),
         ["radius"] = JSON.Element.NewNumber(point.radius),
         ["position"] = Vector3Utils.Vector3ToJSON(point.position),
         ["direction"] = Vector3Utils.Vector3ToJSON(point.direction),
     }));
 }
Beispiel #3
0
 public static JSON.Element ToJSON(Location location)
 {
     return(JSON.Element.NewObject(new Dictionary <string, JSON.Element>()
     {
         ["name"] = JSON.Element.NewString(location.name),
         ["position"] = Vector3Utils.Vector3ToJSON(location.position),
         ["pathsToLocations"] = JSON.Element.NewObject(location.pathsToLocations
                                                       .Select(pathToLocation => new KeyValuePair <string, JSON.Element>(pathToLocation.Key, Waypath.ToJSON(pathToLocation.Value)))
                                                       .ToDictionary(entry => entry.Key, entry => entry.Value)),
     }));
 }
        public static JSON.Element ToJSON(GreedleDirective directive)
        {
            switch (directive.type)
            {
            case DirectiveType.Target:
                return(JSON.Element.NewObject(new Dictionary <string, JSON.Element>()
                {
                    ["type"] = JSON.Element.NewString("target"),
                    ["addressedTo"] = JSON.Element.NewString(directive.targetDirective.addressedTo),
                    ["target"] = Vector3Utils.Vector3ToJSON(directive.targetDirective.target),
                }));

            case DirectiveType.Respond:
                return(JSON.Element.NewObject(new Dictionary <string, JSON.Element>()
                {
                    ["type"] = JSON.Element.NewString("respond"),
                }));
            }
            throw new Exception("Unknown Directive Type");
        }