LazyBot/Assets/Scripts/Navigation/PriorityNearnessNavigation.cs
/// <summary>
/// Return next with higher priority or 
/// random (based on container settings) navigation point.
/// </summary>
/// <param name="destinationIndex">Relative index of navigation point, updates after choosing new point.</param>
/// <returns>Position of target navigation point.</returns>
Return next with higher priority or
random (based on container settings) navigation point.
Return next with higher priority or random ( based on container settings ) navigation point .
public override Vector3 GetDestination(ref int destinationIndex)
        {
            if (Points.Count == 0)
                throw new System.Exception("Can't get destination, navigation is empty.");
            if (_isRandom)
                return GetRandomPoint(ref destinationIndex);
            float distanceTemp = 0.0f,
                  distance = int.MaxValue;
            ushort priority = 0;
            for (int i = 0; i < Points.Count; i++)
            {
                distanceTemp = Vector3.Distance(_ownerTransform.position, Points[i].Transform.position);
                if ((i == _previousPoint) ||
                    (Points[i].Priority < priority)||
                    ((Points[i].Priority == priority) && (distanceTemp - distance > _nearnessPrecision))) continue;
                priority = Points[i].Priority;
                distance = distanceTemp;
                destinationIndex = i;
            }
            return Points[destinationIndex].Transform.position;
        }
public override Vector3 GetDestination ( ref int destinationIndex ) { if ( Points . Count == 0 ) throw new System . Exception ( " " ) ; if ( _isRandom ) return GetRandomPoint ( ref destinationIndex ) ; float distanceTemp = 0.0f , distance = int . MaxValue ; ushort priority = 0 ; for ( int i = 0 ; i < Points . Count ; i ++ ) { distanceTemp = Vector3 . Distance ( _ownerTransform . position , Points [ i ] . Transform . position ) ; if ( ( i == _previousPoint ) || ( Points [ i ] . Priority < priority ) || ( ( Points [ i ] . Priority == priority ) && ( distanceTemp - distance > _nearnessPrecision ) ) ) continue ; priority = Points [ i ] . Priority ; distance = distanceTemp ; destinationIndex = i ; } return Points [ destinationIndex ] . Transform . position ; }
Return next with higher priority or
random (based on container settings) navigation point.
Return next with higher priority or random ( based on container settings ) navigation point .
Position of target navigation point.
Position of target navigation point .
int
ref
destinationIndex
Relative index of navigation point, updates after choosing new point.
Relative index of navigation point updates after choosing new point .