Beispiel #1
0
    private int IntersectionCount(Roads segment, out Vector2 intersection, out Roads other, Roads skip)
    {
        intersection = Vector2.zero;
        other        = null;

        Vector2 tmp      = Vector2.zero;
        Vector2 interTmp = Vector3.zero;

        int count = 0;

        for (int i = 0; i < this.Roads.Count; i++)
        {
            Roads seg = this.Roads[i];
            if (seg.Equals(skip))
            {
                continue;
            }
            else if (Vector2.Distance(seg.start.position, segment.start.position) < 0.01f || Vector2.Distance(seg.end.position, segment.end.position) < 0.01f)
            {
                continue;
            }
            else if (Vector2.Distance(seg.start.position, segment.end.position) < 0.01f || Vector2.Distance(seg.end.position, segment.start.position) < 0.01f)
            {
                continue;
            }
            else if (TwoDimentsionalIntersection(segment, seg, out interTmp, out tmp) != 0)
            {
                other        = seg;
                intersection = new Vector2(interTmp.x, interTmp.y);
                count++;
            }
        }

        return(count);
    }