예제 #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();
        }
    }
예제 #2
0
    public IEnumerator CreatePath(Reciever reciever1, Reciever reciever2, Reciever reciever3)
    {
        path.Clear();
        reciever1.GetTimesList().Clear();
        reciever2.GetTimesList().Clear();
        reciever3.GetTimesList().Clear();

        while (trailRenderer.enabled)
        {
            path.Add(transform.position);

            reciever1.AddTime(Vector3.Distance(transform.position, reciever1.transform.position) / 1000000);
            reciever2.AddTime(Vector3.Distance(transform.position, reciever2.transform.position) / 1000000);
            reciever3.AddTime(Vector3.Distance(transform.position, reciever3.transform.position) / 1000000);

            yield return(new WaitForSeconds(1f));
        }

        yield return(false);
    }