Example #1
0
    public void SaveTrajectory()
    {
        StopCreateTrajectory();

        recieverComp1.SetPosition(recieverGO1.transform.position);
        recieverComp2.SetPosition(recieverGO2.transform.position);
        recieverComp3.SetPosition(recieverGO3.transform.position);

        // using(StreamWriter outputWriter = new StreamWriter(Application.persistentDataPath + "output.txt"))
        using (StreamWriter outputWriter = new StreamWriter("Assets/Resources/output.txt"))
        {
            for (int i = 0; i < sourceComp.GetPath().Count; i++)
            {
                outputWriter.WriteLine(sourceComp.GetPath() [i].x.ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                       sourceComp.GetPath() [i].z.ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat));
            }
            outputWriter.Close();
        }

        // using(StreamWriter inputWriter = new StreamWriter(Application.persistentDataPath + "input.txt"))
        using (StreamWriter inputWriter = new StreamWriter("Assets/Resources/input.txt"))
        {
            inputWriter.WriteLine(recieverComp1.GetPosX().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                  recieverComp1.GetPosY().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                  recieverComp2.GetPosX().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                  recieverComp2.GetPosY().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                  recieverComp3.GetPosX().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                  recieverComp3.GetPosY().ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat));
            for (int i = 0; i < recieverComp1.GetTimesList().Count; i++)
            {
                inputWriter.WriteLine(recieverComp1.GetTime(i).ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                      recieverComp2.GetTime(i).ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat) + "," +
                                      recieverComp3.GetTime(i).ToString("0.00000000", CultureInfo.InvariantCulture.NumberFormat));
            }
            inputWriter.Close();
        }
    }