예제 #1
0
    public void DrawPath()
    {
        GameObject railPath = new GameObject("RailPath");

        // Draw segments
        for (int i = 1; i < PathPoints.Count; i++)
        {
            RailSegment newSegment = RailSegmentMeshGenerator.GenerateRailSegment(railPath, PathPoints[i - 1], PathPoints[i], RailSettings);
            newSegment.Init(PathPoints[i - 1], PathPoints[i], RailSettings);
            RailSegments.Add(newSegment);
        }

        // Init segment connections
        foreach (RailPathPoint rpp in PathPoints)
        {
            foreach (RailSegment rs1 in rpp.Segments)
            {
                foreach (RailSegment rs2 in rpp.Segments)
                {
                    if (rs1 != rs2 && !rs1.ConnectedSegments.Contains(rs2) && !rs2.ConnectedSegments.Contains(rs1))
                    {
                        rs1.ConnectedSegments.Add(rs2);
                        rs2.ConnectedSegments.Add(rs1);
                    }
                }
            }
        }
    }
예제 #2
0
파일: Rail.cs 프로젝트: pmartin36/RailRider
    private RailSegment CreateRailSegment(float size, float spawnAngleDiff, int segIndex, bool corrupted = false, float killTime = 15f)
    {
        RailSegment r = RailSegment.Create();

        r.parentRail = this;
        r.Init(killTime);
        var newNodes = r.CalculateNodes(size, spawnAngleDiff, lastRailSpawnPosition, this.transform.position, corrupted, segIndex);

        nodes.AddRange(newNodes);
        RailSegmentPositions.Add(transform.position);

        previousRailSegment   = r;
        lastRailSpawnPosition = transform.position;
        return(r);
    }