Beispiel #1
0
 //---------------------------------------------------------------------
 public void Start(EbVector3 pos)
 {
     if (mListNode.IsEmpty())
     {
         _clearState();
         return;
     }
     mPrePos     = pos;
     mCurrentPos = mPrePos;
     mNextNode   = _lerpToNextNode();
 }
Beispiel #2
0
 //---------------------------------------------------------------------
 EbRouteNode _lerpToNextNode()
 {
     if (mListNode.IsNotEmpty())
     {
         EbRouteNode pNode = mListNode.GetHead().Data;
         mDir   = pNode._pos - mPrePos;
         mDir.y = 0.0f;
         mDir.normalize();
         return(pNode);
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
        //---------------------------------------------------------------------
        public float Length()
        {
            float     len     = 0.0f;
            EbVector3 pos_pre = mCurrentPos;
            EbDoubleLinkNode2 <EbRouteNode> iter = mListNode.GetHead();

            while (!mListNode.IsEnd(iter))
            {
                EbRouteNode value = iter.Data;
                EbDoubleLinkList2 <EbRouteNode> .Next(ref iter);

                len    += Distance(value._pos, pos_pre);
                pos_pre = value._pos;
            }
            return(len);
        }
Beispiel #4
0
        //---------------------------------------------------------------------
        bool _updateDistance(float distance)
        {
            if (mNextNode == null)
            {
                return(false);
            }
            EbVector3 nextPos   = mNextNode._pos;
            float     distRight = Distance(mCurrentPos, nextPos);

            if (distRight > distance)
            {
                mCurrentPos += mDir * distance;
            }
            else
            {
                float newDistance = distance - distRight;
                mCurrentPos = nextPos;
                mPrePos     = nextPos;

                //if (EbRouteNode.HasEvent(_nextNode._eventId))
                //{
                //    _endCallbackList.Invoke(_nextNode._eventId);
                //}

                mNodeAlloc.Delete(mListNode.GetHead());
                mNextNode = _lerpToNextNode();
                if (mNextNode != null)
                {
                    _updateDistance(newDistance);
                }
                else
                {
                    _clearState();
                }
            }
            return(true);
        }
Beispiel #5
0
 //---------------------------------------------------------------------
 void _clearState()
 {
     mNextNode = null;
     mPrePos   = mCurrentPos;
 }