コード例 #1
0
    void WaitForInput()
    {
        if (Input.GetKeyDown(KeyCode.RightArrow))  // go forwards
        {
            if (currentPath != null && currentPathNumber < Paths.Length)
            {
                distAlongPath = 0.0f;
                seq.Call(MoveForward);
                return;
            }
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))  // go backwards
        {
            if (currentPath != null && currentPathNumber > 0.0f)
            {
                --currentPathNumber;
                currentPath   = Paths[currentPathNumber].GetComponent <FFPath>();
                distAlongPath = currentPath.PathLength;
                seq.Call(MoveBackward);
                return;
            }
        }

        seq.Sync();
        seq.Call(WaitForInput);
    }
コード例 #2
0
ファイル: SplineVisuals.cs プロジェクト: Manquia/Sandbox
    private void GeneratePath(FFPath path)
    {
        // setup first point
        {
            var point = Instantiate(PathPointPrefab);
            point.transform.position = path.PositionAtPoint(0);

            point.SetParent(transform, true);
        }


        for (int i = 1; i < path.PointCount; ++i)
        {
            var pastPt = path.PositionAtPoint(i - 1);
            var pt     = path.PositionAtPoint(i);
            var point  = Instantiate(PathPointPrefab);
            var edge   = Instantiate(PathEdgePrefab);

            // set point
            point.position = pt;
            point.SetParent(transform, true);


            // setup edge
            {
                var vecToPt = pt - pastPt;
                var edgePos = pastPt + (vecToPt * 0.5f);

                edge.position   = edgePos;
                edge.up         = vecToPt.normalized;
                edge.localScale = new Vector3(1, vecToPt.magnitude, 1);
                edge.SetParent(transform, true);
            }
        }
    }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     if (Paths.Length > 0)
     {
         seq = action.Sequence();
         seq.Call(WaitForInput);
         currentPath = Paths[0].GetComponent <FFPath>();
     }
 }
コード例 #4
0
    void MoveForward()
    {
        if (distAlongPath >= currentPath.PathLength)                                 // reached end of path
        {
            transform.position = currentPath.PointAlongPath(currentPath.PathLength); // goto end
            ++currentPathNumber;

            if (currentPathNumber < Paths.Length)
            {
                currentPath = Paths[currentPathNumber].GetComponent <FFPath>();
            }

            seq.Call(WaitForInput); // waitForInput
            return;
        }
        else
        {
            transform.position = currentPath.PointAlongPath(distAlongPath);
        }

        distAlongPath += Time.deltaTime * ComicCameraSpeed;
        seq.Sync();
        seq.Call(MoveForward);
    }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     path = GetComponent <FFPath>();
     Debug.Assert(path.points.Length == 2);
 }
コード例 #6
0
ファイル: WarpSpline.cs プロジェクト: Manquia/Sandbox
 // Use this for initialization
 void Start()
 {
     path = GetComponent <FFPath>();
 }