Ejemplo n.º 1
0
        private Vector3?GetTaskPosition(Task task)
        {
            if (!IsPointableTask(task))
            {
                return(null);
            }
            if (IsPositionCached(task))
            {
                return(lastTaskPosition);
            }

            Vector3?     objectivePosition = null;
            LocationData currentLocation   = locationManager.CurrentLocation;

            // task is in another location, find an exit to get closer
            if (!task.Location.Equals(currentLocation))
            {
                LocationData nextScene = currentLocation.NextLocationTo(task.Location);
                if (nextScene == null)
                {
                    Debug.LogWarning("Could not find location path between "
                                     + currentLocation + " and " + task.Location);
                    return(null);
                }
                objectivePosition = spawnManager.GetExit(nextScene);
            }
            else // task is in current location, find position in scene
            {
                objectivePosition = objectiveTransformManager.GetTransformOfTask(task)?.position;
            }

            lastTaskPointedAt = task;
            lastTaskPosition  = objectivePosition;
            return(objectivePosition);
        }