コード例 #1
0
    public bool Save(string filepath, FishPath path)
    {
        JsonPath jsonPath = new JsonPath();

        jsonPath.pointList = new List <JsonControlPoint>();
        jsonPath.r         = (int)path.lineColour.r;
        jsonPath.g         = (int)path.lineColour.g;
        jsonPath.b         = (int)path.lineColour.b;
        jsonPath.baseSpeed = (int)path.baseSpeed;
        foreach (FishPathControlPoint point in path.controlPoints)
        {
            JsonControlPoint cp = new JsonControlPoint();
            cp.time       = point.mTime;
            cp.speedScale = point.mSpeedScale;
            cp.rx         = point.mRotationChange.x;
            cp.ry         = point.mRotationChange.y;
            jsonPath.pointList.Add(cp);
        }
        string       json = JsonMapper.ToJson(jsonPath);
        FileStream   fs   = new FileStream(filepath, FileMode.Create);
        StreamWriter sw   = new StreamWriter(fs);

        sw.Write(json);
        sw.Flush();
        fs.Close();
        return(true);
    }
コード例 #2
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);
    }