Example #1
0
    private void Setup()
    {
        using (StreamReader inputReader = new StreamReader("Assets/Resources/input.txt"))
        {
            string   line      = inputReader.ReadLine();
            string[] lineSplit = line.Split(',');

            recieverComp1.SetPosition(new Vector3(float.Parse(lineSplit[0], CultureInfo.InvariantCulture.NumberFormat), 0,
                                                  float.Parse(lineSplit[1], CultureInfo.InvariantCulture.NumberFormat)));
            recieverComp2.SetPosition(new Vector3(float.Parse(lineSplit[2], CultureInfo.InvariantCulture.NumberFormat), 0,
                                                  float.Parse(lineSplit[3], CultureInfo.InvariantCulture.NumberFormat)));
            recieverComp3.SetPosition(new Vector3(float.Parse(lineSplit[4], CultureInfo.InvariantCulture.NumberFormat), 0,
                                                  float.Parse(lineSplit[5], CultureInfo.InvariantCulture.NumberFormat)));

            while ((line = inputReader.ReadLine()) != null)
            {
                lineSplit = line.Split(',');

                recieverComp1.AddTime(float.Parse(lineSplit[0], CultureInfo.InvariantCulture.NumberFormat));
                recieverComp2.AddTime(float.Parse(lineSplit[1], CultureInfo.InvariantCulture.NumberFormat));
                recieverComp3.AddTime(float.Parse(lineSplit[2], CultureInfo.InvariantCulture.NumberFormat));
            }

            for (int i = 0; i < recieverComp1.GetTimesList().Count; i++)
            {
                sourceComp.AddPosition(FindSourcePosition(recieverComp1.GetPosX(), recieverComp1.GetPosY(), recieverComp1.GetDistanceToSource(i),
                                                          recieverComp2.GetPosX(), recieverComp2.GetPosY(), recieverComp2.GetDistanceToSource(i),
                                                          recieverComp3.GetPosX(), recieverComp3.GetPosY(), recieverComp3.GetDistanceToSource(i)));
            }

            inputReader.Close();
        }
    }