//--------------------------------------------------------------------- public void Start(EbVector3 pos) { if (mListNode.IsEmpty()) { _clearState(); return; } mPrePos = pos; mCurrentPos = mPrePos; mNextNode = _lerpToNextNode(); }
//--------------------------------------------------------------------- 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); } }
//--------------------------------------------------------------------- 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); }
//--------------------------------------------------------------------- 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); }
//--------------------------------------------------------------------- void _clearState() { mNextNode = null; mPrePos = mCurrentPos; }