示例#1
0
    /// <summary>
    /// Return a vector of points that specifies the path created
    /// </summary>
    /// <returns>The tunnel points.</returns>
    private Vector2[] UpdateThenReturnNewTunnelPositions(float deltatime)
    {
        GameObject tunnel          = tunnelInBack;
        Tunnel     tunnelComponent = tunnel != null?tunnel.GetComponent <Tunnel>() : null;

        List <Vector2> leftSide  = new List <Vector2>();
        List <Vector2> rightSide = new List <Vector2>();

        // if tunnel is not null and if tunnel is still in view
        while (tunnel != null && !tunnelComponent.IsTunnelOutOfBounds())
        {
            tunnelComponent.UpdateTunnelPosition(deltatime);
            leftSide.Add(tunnelComponent.GetLeftSide());
            rightSide.Add(tunnelComponent.GetRightSide());

            tunnel          = tunnelComponent.GetTunnelInFront();
            tunnelComponent = tunnel != null?tunnel.GetComponent <Tunnel>() : null;
        }

        // create an array of vertices, we will these all together
        rightSide.Reverse();
        leftSide.AddRange(rightSide);

        return(leftSide.ToArray());
    }