예제 #1
0
    private void Generate()
    {
        curves = new Curve[curveCount];
        for (int i = 0; i < curves.Length; i++)
        {
            Curve curve = curves[i] = Instantiate <Curve>(curvePrefab);
            curve.Create(generatePipes);
            curve.transform.SetParent(transform);
            if (i > 0)
            {
                curve.AlignWith(curves[i - 1]);
            }
            if (i != FIRST_CURVE && i != SECOND_CURVE)
            {
                curve.GenerateObstacles();
            }
        }
        finishedGenerating = true;

        //Position the curves at 0,0
        //The setup is done with the second curve to avoid seeing the pipes disappear
        transform.localPosition = new Vector3(0, -curves[SECOND_CURVE].GetTorusRadius(), 0);

        //Align with controller axis
        transform.rotation = Quaternion.Euler(0, -90, 0);

        AlignCurveWithOrigin();
    }