コード例 #1
0
    private void ExportWayPoints()
    {
        //TraceConfig config = new TraceConfig();
        List <MovePoint>             config          = _path.GetMovePoints();
        List <MovePointSerializable> configSerialize = new List <MovePointSerializable>();

        foreach (var item in config)
        {
            MovePointSerializable tmp = new MovePointSerializable(item);
            configSerialize.Add(tmp);
        }
        TraceConfigSerializable result = new TraceConfigSerializable {
            MovePoints = configSerialize
        };

        DataAccessor.SaveObjectToJsonFile <TraceConfigSerializable>(result, DataAccessor.GetTracePathByID(System.Convert.ToInt32(_path.name)));
//		List<MovePoint> wayPoints = new List<MovePoint>();
//		List<Vector3> points = _path.GetPoints();
//		for (int i = 0; i < points.Count; i++)
//		{
//			if(i < points.Count-1)
//			{
//				wayPoints.Add(new MovePoint(points[i], GetAngle(points[i], points[i+1])));
//			}
//			else
//			{
//				wayPoints.Add(new MovePoint(points[i]));
//			}
//		}
//		string json = JsonMapper.ToJson(wayPoints);
//		string savePath = EditorUtility.SaveFilePanel("Save Way Points", string.Empty, "data", "dat");
//		System.IO.TextWriter tw = new System.IO.StreamWriter(savePath);
//		if(tw == null)
//		{
//			Debug.LogError("Cannot write to " + savePath);
//			return;
//		}
//		tw.Write(json);
//		tw.Flush();
//		tw.Close();
    }
コード例 #2
0
ファイル: PathEditor.cs プロジェクト: sishui/Smart2DWaypoints
        private void ExportWayPoints()
        {
            List <MovePoint>             movePoints      = _path.GetMovePoints();
            List <MovePointSerializable> configSerialize = new List <MovePointSerializable>();

            foreach (var item in movePoints)
            {
                MovePointSerializable tmp = new MovePointSerializable(item);
                configSerialize.Add(tmp);
            }

            PathConfigSerializable result = new PathConfigSerializable {
                MovePoints = configSerialize
            };
            var        filename = "Assets/art/game/fish/Track/" + _path.name + ".bytes";
            TextWriter tw       = new StreamWriter(filename);
            string     jsonStr  = JsonMapper.ToJson(result);

            tw.Write(jsonStr);
            tw.Flush();
            tw.Close();
        }
コード例 #3
0
ファイル: PathEditor.cs プロジェクト: ShyoZarak/FishEditor
	private void ExportWayPoints()
	{
		//TraceConfig config = new TraceConfig();
		List<MovePoint> config = _path.GetMovePoints();
		List<MovePointSerializable> configSerialize = new List<MovePointSerializable>();
		foreach (var item in config) 
		{
			MovePointSerializable tmp = new MovePointSerializable(item);
			configSerialize.Add(tmp);
		}
		TraceConfigSerializable result = new TraceConfigSerializable{MovePoints = configSerialize};
		DataAccessor.SaveObjectToJsonFile<TraceConfigSerializable>(result, DataAccessor.GetTracePathByID(System.Convert.ToInt32(_path.name)));
//		List<MovePoint> wayPoints = new List<MovePoint>();
//		List<Vector3> points = _path.GetPoints();
//		for (int i = 0; i < points.Count; i++) 
//		{
//			if(i < points.Count-1)
//			{
//				wayPoints.Add(new MovePoint(points[i], GetAngle(points[i], points[i+1])));
//			}
//			else
//			{
//				wayPoints.Add(new MovePoint(points[i]));
//			}
//		}
//		string json = JsonMapper.ToJson(wayPoints);
//		string savePath = EditorUtility.SaveFilePanel("Save Way Points", string.Empty, "data", "dat");
//		System.IO.TextWriter tw = new System.IO.StreamWriter(savePath);
//		if(tw == null)
//		{
//			Debug.LogError("Cannot write to " + savePath);
//			return;
//		}
//		tw.Write(json);
//		tw.Flush();
//		tw.Close();
	}