/// <summary> /// Create a new single spline <see cref="SplinePath"/> with supplied <see cref="SplineMode"/> and speed. /// </summary> public SplinePath(ushort splineId, SplineMode mode, float speed) { Type = SplineType.CatmullRom; Mode = mode; Speed = speed; SplineTypeBase splineType = new SplineTypeCatmullRomTbl(); ISplineMode splineMode = GlobalMovementManager.NewSplineMode(mode); if (splineMode == null) { throw new ArgumentOutOfRangeException(); } spline = new Spline(); spline.Initialise(splineId, splineType, splineMode); direction = splineMode.InitialDirection; point = direction == SplineDirection.Forward ? splineType.BottomIndex : splineType.BottomReverseIndex; remaining = spline.GetNextLength(direction, point); }
/// <summary> /// Create a new custom spline <see cref="SplinePath"/> with supplied <see cref="SplineType"/>, <see cref="SplineMode"/> and speed. /// </summary> public SplinePath(List <Vector3> nodes, SplineType type, SplineMode mode, float speed) { Type = type; Mode = mode; Speed = speed; SplineTypeBase splineType; switch (type) { case SplineType.Linear: splineType = new SplineTypeLinear(); break; case SplineType.CatmullRom: splineType = new SplineTypeCatmullRom(); break; default: throw new ArgumentOutOfRangeException(); } ISplineMode splineMode = GlobalMovementManager.NewSplineMode(mode); if (splineMode == null) { throw new ArgumentException(); } spline = new Spline(); spline.Initialise(nodes, splineType, splineMode); direction = splineMode.InitialDirection; point = direction == SplineDirection.Forward ? splineType.BottomIndex : splineType.BottomReverseIndex; remaining = spline.GetNextLength(direction, point); }