コード例 #1
0
        private void AddIsolatedSignalLight()
        {
            List <SignalLight> linked = new List <SignalLight>();

            foreach (var item in StopLine.List)
            {
                linked.AddRange(item.signalLights.Where(_ => _ != null));
            }
            foreach (var item in SignalLight.List)
            {
                if (!linked.Contains(item))
                {
                    var csvPoint = new CsvPoint()
                    {
                        Position = item.transform.position
                    };
                    csvPoints.Add(csvPoint);
                    var csvVector = new CsvVector()
                    {
                        Point = csvPoint, Rotation = item.transform.rotation
                    };
                    csvVectors.Add(csvVector);
                    var csvSignalLight = new CsvSignalLight()
                    {
                        Vector = csvVector
                    };
                    csvSignalLights.Add(csvSignalLight);
                }
            }
        }
コード例 #2
0
        public static void GetCsvData(this StopLine stopLine,
                                      PointOctree <CsvLane> finalLanes,
                                      out List <CsvPoint> csvPoints,
                                      out List <CsvLine> csvLines,
                                      out List <CsvVector> csvVectors,
                                      out List <CsvSignalLight> csvSignalLights,
                                      out List <CsvStopLine> csvStopLines)
        {
            csvPoints    = new List <CsvPoint>();
            csvLines     = new List <CsvLine>();
            csvStopLines = new List <CsvStopLine>();
            var csvSLPoints = new List <CsvPoint>();

            csvVectors      = new List <CsvVector>();
            csvSignalLights = new List <CsvSignalLight>();
            for (int i = 0; i < stopLine.Count; i++)
            {
                var csvPoint = new CsvPoint()
                {
                    Position = stopLine.LineRenderer.GetPosition(i)
                };
                csvPoints.Add(csvPoint);
                if (i > 0)
                {
                    var csvLine = new CsvLine()
                    {
                        PointBegin = csvPoints[i - 1], PointFinal = csvPoint
                    };
                    if (i > 1)
                    {
                        csvLine.LineLast = csvLines.Last();
                    }
                    csvLines.Add(csvLine);
                    var signalLight = stopLine.signalLights[i - 1];
                    var csvSLPoint  = new CsvPoint()
                    {
                        Position = signalLight.transform.position
                    };
                    csvSLPoints.Add(csvSLPoint);
                    var csvVector = new CsvVector()
                    {
                        Point = csvSLPoint, Rotation = signalLight.transform.rotation
                    };
                    csvVectors.Add(csvVector);
                    var csvSignalLight = new CsvSignalLight()
                    {
                        Vector = csvVector
                    };
                    csvSignalLights.Add(csvSignalLight);
                    var midPoint    = (csvLine.PointBegin.Position + csvLine.PointFinal.Position) / 2;
                    var csvStopLine = new CsvStopLine()
                    {
                        Line        = csvLine,
                        SignalLight = csvSignalLight,
                        Lane        = finalLanes
                                      .GetNearby(midPoint, Vector3.Distance(csvLine.PointBegin.Position, csvLine.PointFinal.Position))
                                      ?.OrderBy(_ => Vector3.Distance(_.FinalNode.Point.Position, midPoint))?
                                      .FirstOrDefault()
                    };
                    csvStopLines.Add(csvStopLine);
                }
            }
            csvPoints.AddRange(csvSLPoints);
        }