Ejemplo n.º 1
0
 void DeserializeState(JSON.Element state)
 {
     paths.Clear();
     paths.AddRange(
         state
         .jsonObject["paths"].jsonArray
         .Select(element => Waypath.FromJSON(element))
         );
     currentPathIndex = (int)state.jsonObject["paths"].jsonNumber;
     if (paths.Count < 1)
     {
         paths.Add(new Waypath(name: "Default Waypath", points: new List <Waypoint>()));
         currentPathIndex = 0;
     }
     recorder.SetPath(paths[currentPathIndex]);
     traveller.SetPath(paths[currentPathIndex]);
     traveller.LoadState(state.jsonObject["traveler"]);
     DrawPaths();
 }
 public void LoadState(JSON.Element rootElement)
 {
     paths = rootElement.jsonObject["paths"].jsonArray.Select(element => Waypath.FromJSON(element)).ToList();
     DrawOutput();
 }
Ejemplo n.º 3
0
 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)
     });
 }