コード例 #1
0
        /// <summary>
        /// Initialise a new single spline with supplied <see cref="SplineTypeBase"/> and <see cref="ISplineMode"/>.
        /// </summary>
        public void Initialise(ushort splineId, SplineTypeBase splineType, ISplineMode splineMode)
        {
            type = splineType;
            mode = splineMode;

            Spline2Entry splineEntry = GameTableManager.Instance.Spline2.GetEntry(splineId);

            if (splineEntry == null)
            {
                throw new ArgumentException();
            }

            foreach (Spline2NodeEntry node in GameTableManager.Instance.Spline2Node.Entries
                     .Where(s => s.SplineId == splineId)
                     .OrderBy(s => s.Ordinal))
            {
                // TODO
                if (node.Delay > 0f)
                {
                    throw new NotImplementedException();
                }

                var position = new Vector3(node.Position0, node.Position1, node.Position2);
                points.Add(new SplinePoint(position)
                {
                    Length = node.FrameTime
                });
            }

            splineType.Initialise((uint)points.Count);

            Length = splineType.CalculateLengths(points);
        }
コード例 #2
0
        /// <summary>
        /// Initialise a new custom spline with supplied <see cref="SplineTypeBase"/> and <see cref="ISplineMode"/>.
        /// </summary>
        public void Initialise(List <Vector3> nodes, SplineTypeBase splineType, ISplineMode splineMode)
        {
            type = splineType;
            mode = splineMode;

            foreach (Vector3 position in nodes)
            {
                points.Add(new SplinePoint(position));
            }

            splineType.Initialise((uint)points.Count);

            Length = splineType.CalculateLengths(points);
        }
コード例 #3
0
        /// <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.Instance.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);
        }
コード例 #4
0
        /// <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.Instance.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);
        }