Ejemplo n.º 1
0
    public bool Save(string filepath, FishPath path)
    {
        JsonPath jsonPath = new JsonPath();

        jsonPath.id        = path.mPathId;
        jsonPath.pointList = new List <JsonControlPoint>();
        foreach (FishPathControlPoint point in path.controlPoints)
        {
            JsonControlPoint cp = new JsonControlPoint();
            cp.time       = point.mTime;
            cp.speedScale = point.mSpeedScale;
            cp.r          = point.mRotationChange;
            jsonPath.pointList.Add(cp);
        }
        string       json = jsonPath.GetJson();
        FileStream   fs   = new FileStream(filepath, FileMode.Create);
        StreamWriter sw   = new StreamWriter(fs);

        sw.Write(json);
        sw.Flush();
        fs.Close();
        return(true);
    }