コード例 #1
0
        public override void CachePath()
        {
            if (LockedAxis != Axis.None)
            {
                LockAxis(LockedAxis);
            }
            if (_path == null)
            {
                _path = GetComponent <PathComponent>();
            }
            var nonUniform = _path.Path as NonUniformPath;

            if (nonUniform == null)
            {
                nonUniform = new NonUniformPath();
            }
            var currPathLength = nonUniform.Points == null ? 0 : nonUniform.Points.Length;
            var requiredPoints = Points.Length + (_isCyclic ? 1 : 0);

            if (currPathLength != requiredPoints)
            {
                nonUniform.Points = new Vector3[requiredPoints];
            }
            for (int i = 0; i < requiredPoints; i++)
            {
                nonUniform.Points[i] = GetPointPosition(i % Points.Length);
            }
            nonUniform.RecalculateDistances();
            _path.StorePath(nonUniform);
        }
コード例 #2
0
 public void StorePath(IPath path)
 {
     _isNonUniformPath = path is NonUniformPath;
     _nonUniformPath   = path as NonUniformPath;
     _isUniformPath    = path is UniformPath;
     _uniformPath      = path as UniformPath;
 }
コード例 #3
0
        public void CheckInitialization()
        {
            var path = new NonUniformPath();

            Assert.IsNull(path.Points);
            Assert.IsNull(path.Distances);
            path.Points = new Vector3[0];
            path.RecalculateDistances();
            Assert.IsNull(path.Distances);
            Assert.AreEqual(0, path.TotalLength);
            path.Points = new[] { Vector3.zero, Vector3.up };
            path.RecalculateDistances();
            Assert.AreEqual(1, path.SegmentsCount);
            Assert.AreEqual(1, path.TotalLength);
        }