Exemplo n.º 1
0
        private NavigationData GetReachableNavigationDataForWander(ActorData actorData, Vector2Int targetAreaCenter, int wanderRange)
        {
            NavigationData newNavigationData;

            while (true)
            {
                Vector2Int wanderVector      = new Vector2Int(_rng.Next(-wanderRange, wanderRange), _rng.Next(-wanderRange, wanderRange));
                Vector2Int newTargetPosition = targetAreaCenter + wanderVector;
                if (newTargetPosition == actorData.LogicalPosition)
                {
                    continue;
                }
                List <Vector2Int> path = _navigator.GetPath(actorData.LogicalPosition, newTargetPosition);
                if (path == null)
                {
                    continue;
                }
                newNavigationData = new NavigationData
                {
                    Destination  = newTargetPosition,
                    PathToFollow = path
                };
                break;
            }
            return(newNavigationData);
        }