Ejemplo n.º 1
0
    public List <Vector3> GetPath(bool forward)
    {
        List <Vector3> result = new List <Vector3>();

        for (int i = 0; i < vertexZebraCrossingHead.Count; i += 2)
        {
            result.Add(SpeedRoadUtils.SwapYZ(vertexZebraCrossingHead[i]));
        }
        for (int i = 0; i < vertexWaitingHead.Count; i += 2)
        {
            result.Add(SpeedRoadUtils.SwapYZ(vertexWaitingHead[i]));
        }
        for (int i = 0; i < vertexRoad.Count; i += 2)
        {
            result.Add(SpeedRoadUtils.SwapYZ(vertexRoad[i]));
        }
        for (int i = 0; i < vertexWaitingTail.Count; i += 2)
        {
            result.Add(SpeedRoadUtils.SwapYZ(vertexWaitingTail[i]));
        }
        for (int i = 0; i < vertexZebraCrossingTail.Count; i += 2)
        {
            result.Add(SpeedRoadUtils.SwapYZ(vertexZebraCrossingTail[i]));
        }

        if (!forward)
        {
            result.Reverse();
        }
        return(result);
    }
Ejemplo n.º 2
0
    public float GetRoadAngle(bool bhead, ref List <Vector3> lst)
    {
        float          angle  = 0;
        List <Vector3> vertex = null;

        if (bhead)
        {
            if (vertexZebraCrossingHead.Count > 0)
            {
                vertex = vertexZebraCrossingHead;
            }
            else if (vertexRoad.Count > 0)
            {
                vertex = vertexRoad;
            }
            else
            {
                Assert.IsFalse(true);
            }
            var dst = vertex[2] - vertex[0];
            angle = SpeedRoadUtils.AngleBetween(Vector3.right, new Vector3(dst.x, dst.y, 0));
            lst.Add(SpeedRoadUtils.SwapYZ(vertex[0]));
            lst.Add(SpeedRoadUtils.SwapYZ(vertex[1]));
        }
        else
        {
            if (vertexZebraCrossingTail.Count > 0)
            {
                vertex = vertexZebraCrossingTail;
            }
            else if (vertexRoad.Count > 0)
            {
                vertex = vertexRoad;
            }
            else
            {
                Assert.IsFalse(true);
            }
            var dst = vertex[vertex.Count - 4] - vertex[vertex.Count - 2];
            angle = SpeedRoadUtils.AngleBetween(Vector3.right, new Vector3(dst.x, dst.y, 0));
            lst.Add(SpeedRoadUtils.SwapYZ(vertex[vertex.Count - 1]));
            lst.Add(SpeedRoadUtils.SwapYZ(vertex[vertex.Count - 2]));
        }
        return(angle);
    }