Esempio n. 1
0
        public void CreateRoutePoints()
        {
            var startPoint  = calculatedDevicePoint - Scholar.GPSCoorToPoint(startLocation);
            var targetPoint = calculatedDevicePoint - Scholar.GPSCoorToPoint(targetLocation);
            var stepPoints  = new List <Vector3>()
            {
                new Vector3(0, 0, 0),
                new Vector3(targetPoint.x, 0, targetPoint.y)
            };

            try
            {
                worldRouteRenderer.positionCount = stepPoints.Count;
                worldRouteRenderer.SetPositions(stepPoints.ToArray());
            }
            catch (UnityException)
            {
                ThreadManager.ExecuteInUpdate(() =>
                {
                    worldRouteRenderer.positionCount = stepPoints.Count;
                    worldRouteRenderer.SetPositions(stepPoints.ToArray());
                });
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
Esempio n. 2
0
 public void UpdateWorldPoints()
 {
     knownTargets.ForEach(target =>
     {
         var position = calculatedDevicePoint - Scholar.GPSCoorToPoint(target.Location);
         target.transform.localPosition = new Vector3(position.x, 0, position.y);
     });
 }
Esempio n. 3
0
        private void OnValidate()
        {
            //clamping distances and time
            gpsAccuracy    = Mathf.Max(gpsAccuracy, 0.1f);
            searchRadius   = Mathf.Max(searchRadius, 1.0f);
            deviceRadius   = Mathf.Clamp(deviceRadius, 0.5f, searchRadius);
            updateDistance = Mathf.Max(updateDistance, 0.1f);
            updateInterval = Mathf.Max(updateInterval, 1.0f);

            //calcalute device coor in x and y
            calculatedDevicePoint = Scholar.GPSCoorToPoint(deviceLocation);
            calculatedTargetPoint = Scholar.GPSCoorToPoint(targetLocation);
            calculatedStartPoint  = Scholar.GPSCoorToPoint(startLocation);
        }
Esempio n. 4
0
        public void CreateRoutePoints(GoogleRoute[] routes)
        {
            if (routes == null)
            {
                return;
            }

            var stepPoints    = new List <Vector3>();
            var pointPosition = new Vector3();

            foreach (var route in routes)
            {
                foreach (var leg in route.legs)
                {
                    pointPosition = calculatedDevicePoint - Scholar.GPSCoorToPoint(leg.start_location);
                    stepPoints.Add(new Vector3(pointPosition.x, 0, pointPosition.y));

                    foreach (var step in leg.steps)
                    {
                        pointPosition = calculatedDevicePoint - Scholar.GPSCoorToPoint(step.end_location);
                        stepPoints.Add(new Vector3(pointPosition.x, 0, pointPosition.y));
                    }
                }
            }

            try
            {
                worldRouteRenderer.positionCount = stepPoints.Count;
                worldRouteRenderer.SetPositions(stepPoints.ToArray());
            }
            catch (UnityException)
            {
                ThreadManager.ExecuteInUpdate(() =>
                {
                    worldRouteRenderer.positionCount = stepPoints.Count;
                    worldRouteRenderer.SetPositions(stepPoints.ToArray());
                });
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            lastUsedRoutes.Clear();
            lastUsedRoutes.AddRange(routes);
        }
Esempio n. 5
0
        public void CreateWorldPoints(GooglePlace[] places)
        {
            knownTargets.Clear();

            try
            {
                var allPlaces = places.Concat(predefinedPlaces);

                foreach (var place in allPlaces)
                {
                    //excluding desired types
                    var typesToInclude = typesToExclude.Except(place.types).ToArray();
                    if (!typesToInclude.SequenceEqual(typesToExclude))
                    {
                        continue;
                    }
                    //calculating world position
                    var position = calculatedDevicePoint - Scholar.GPSCoorToPoint(place.geometry.location);
                    if (position.magnitude < deviceRadius)
                    {
                        continue;
                    }
                    var target = Instantiate(worldTargetPrefab);
                    //setting new target
                    target.transform.SetParent(worldRoot);
                    target.transform.position = new Vector3(position.x, 0, position.y);

                    target.Place = new PointOfInterest
                    {
                        name    = place.name,
                        address = new Address
                        {
                            location = place.geometry.location
                        }
                    };

                    //saving new target
                    knownTargets.Add(target);
                }
            }
            catch (NullReferenceException e)
            {
                Debug.LogError(e);
            }
        }