Пример #1
0
        void Reset()
        {
            duration = Mathf.Clamp(duration, float.Epsilon, duration);

            CleanUp();
            float curLength = 0;

            for (int i = 0; i < pathPoints.Length - 1; ++i)
            {
                curLength = (pathPoints[i + 1] - pathPoints[i]).magnitude;
                if (curLength == 0)
                {
                    continue;
                }

                SegInfo si = new SegInfo
                {
                    FromPos    = pathPoints[i],
                    ToPos      = pathPoints[i + 1],
                    length     = curLength,
                    isReversed = false,
                };
                segInfoList.Add(si);
                length += curLength;
            }

            valid = segInfoList.Count > 0;

            if (valid)
            {
                speed = length / duration;
            }
        }
Пример #2
0
 public void Restart()
 {
     Reset();
     if (valid)
     {
         curSegInfo = segInfoList[0];
         UpdateRotation();
     }
 }
Пример #3
0
 void OnSegEnd()
 {
     onSegEnd?.Invoke(curSegIndex);
     curSegProgess -= curSegInfo.length;
     curSegIndex++;
     if (curSegIndex < segInfoList.Count)
     {
         curSegInfo = segInfoList[curSegIndex];
         UpdateRotation();
     }
     else
     {
         OnLoopEnd();
     }
 }
Пример #4
0
 void OnLoopEnd()
 {
     onLoopEnd?.Invoke(curLoopIndex);
     curLoopIndex++;
     if (loops < 0 || curLoopIndex < loops)
     {
         if (loopType == LoopType.PingPong)
         {
             segInfoList.Reverse();
             IsReversed = segInfoList.IsReversed;
         }
         curSegIndex = 0;
         curSegInfo  = segInfoList[curSegIndex];
         UpdateRotation();
         curSegProgess = 0;
     }
     else
     {
         valid = false;
     }
 }
Пример #5
0
 public void Add(SegInfo segInfo)
 {
     segInfoList.Add(segInfo);
 }