示例#1
0
        protected override void ConfigureAnnotationObjectRange(MapAnnotation <LocationTaskDriver> annotation, AnnotationGameObject annotationObj)
        {
            if (annotationObj &&
                annotation.Data.Task.ActionRange != null)
            {
                annotationObj.RangeDisplayMode = AnnotationRangeDisplayMode.WhenSelected;

                var range = annotation.Data.Range;

                if (range != 0)
                {
                    if (range > 0)
                    {
                        // Normal range: you have to be "within" this range to
                        annotationObj.Range = (float)range;

                        annotationObj.InRangeColor    = RangeCircleColor;
                        annotationObj.OutOfRangeColor = OutOfRangeColor;
                    }
                    else if (annotation.Data.Task.ActionRange.Min.HasValue)
                    {
                        // Inverse range: you have to be outside of this range
                        annotationObj.Range = (float)-range;

                        annotationObj.InRangeColor    = InvertRangeCircleColor;
                        annotationObj.OutOfRangeColor = OutOfRangeColor;
                    }
                }
            }
        }
示例#2
0
        public override AnnotationGameObject GetObjectForAnnotation(MapAnnotation <LocationTaskDriver> annotation)
        {
            AnnotationGameObject annotationObj = null;

            if (annotation.Data.Task.MarkerAssetInstance != null)
            {
                annotationObj = MapController.Instance.Create3DAssetAnnotation(annotation.Data.Task.MarkerAssetInstance);
            }
            else if (annotation.Data.Task.Marker != null)
            {
                annotationObj = MapMarkerAnnotationHandler.Instance.CreateMarkerAnnotation(annotation.Data.Task.Marker);
            }
            else if (UseTaskImageForAnnotation && annotation.Data.Task.ImageUrl != null)
            {
                var imgAnnot = Instantiate <CustomImageAnnotation>(MapMarkerAnnotationHandler.Instance.CustomImageAnnotation);

                annotationObj = imgAnnot;

                annotationObj.gameObject.SetActive(false);

                StartCoroutine(ImageLoader.LoadImage(annotation.Data.Task.ImageUrl, imgAnnot.gameObject, true, () =>
                {
                    annotationObj.gameObject.SetActive(true);
                }));
            }
            else
            {
                annotationObj = Instantiate <AnnotationGameObject>(GetPrefabForAnnotation(annotation));
            }

            base.ConfigureAnnotationObject(annotation, annotationObj);

            return(annotationObj);
        }
示例#3
0
 public void DeselectAnnotation(MapAnnotation annotation)
 {
     if (OnDeselect != null)
     {
         OnDeselect(annotation);
     }
 }
示例#4
0
        public virtual void SelectAnnotation(MapAnnotation mapAnnotation)
        {
            var oldSelected = SelectedAnnotation;

            SelectedAnnotation = mapAnnotation;

            if (mapAnnotation != null &&
                mapAnnotation.Delegate != null)
            {
                mapAnnotation.Delegate.SelectAnnotation(mapAnnotation);
            }
            else
            {
                //ShowSelectedLocationPanel(mapAnnotation, DefaultSelectedLocationPanel);

                if (mapAnnotation != null)
                {
                    CenterMap(mapAnnotation.Coordinates);
                }
            }

            if (mapAnnotation != oldSelected &&
                oldSelected != null &&
                oldSelected.Delegate != null)
            {
                oldSelected.Delegate.DeselectAnnotation(oldSelected);
            }
        }
示例#5
0
 public void PanZoomTo(MapAnnotation ann, Motive.Core.Models.Vector span, float duration, Action onComplete = null)
 {
     PanZoomTo(ann.Coordinates, span, duration, () =>
     {
         SelectAnnotation(ann);
     });
 }
        public virtual MapAnnotation <D> AddTaskAnnotation(D driver, Location location)
        {
            var annotation = new MapAnnotation <D>(location, driver);

            AddTaskAnnotation(driver, annotation);

            return(annotation);
        }
示例#7
0
        public override MapAnnotation <LocationTaskDriver> AddTaskAnnotation(LocationTaskDriver taskDriver, Location loc)
        {
            var ann = new MapAnnotation <LocationTaskDriver>(loc, taskDriver);

            ann.Marker        = taskDriver.Task.Marker;
            ann.AssetInstance = taskDriver.Task.MarkerAssetInstance;

            return(base.AddTaskAnnotation(taskDriver, loc));
        }
示例#8
0
        public AnnotationGameObject GetObjectForAnnotation(MapAnnotation annotation)
        {
            if (OnGetObjectForAnnotation != null)
            {
                return(OnGetObjectForAnnotation(annotation));
            }

            return(null);
        }
示例#9
0
        public override void DeselectAnnotation(MapAnnotation annotation)
        {
            var panel = GetSelectedLocationPanel();

            if (panel)
            {
                SelectedLocationPanelHandler.Instance.HideSelectedLocationPanel(panel, annotation);
            }
        }
        /// <summary>
        /// Configures the annotation object. In this case looks for a task info component and populates
        /// it with annotation data.
        /// </summary>
        /// <param name="obj"></param>
        protected override void ConfigureAnnotationObject(MapAnnotation <D> annotation, AnnotationGameObject obj)
        {
            var infoComponent = obj.GetComponentInChildren <PlayerTaskInfoComponent>();

            if (infoComponent)
            {
                infoComponent.Populate(annotation.GetData());
            }

            base.ConfigureAnnotationObject(annotation, obj);
        }
示例#11
0
        public void AddAnnotation(MapAnnotation annotation)
        {
            lock (m_toRemove)
            {
                m_toRemove.Remove(annotation);
            }

            m_locationAnnotations.Add(annotation.Location.Id, annotation);

            lock (m_toAdd)
            {
                m_toAdd.Add(annotation);
            }
        }
示例#12
0
        public override void SelectAnnotation(MapAnnotation annotation)
        {
            var panel = GetSelectedLocationPanel();

            if (panel)
            {
                SelectedLocationPanelHandler.Instance.ShowSelectedLocationPanel(panel, annotation);

                ConfigureSelectedLocationPanel(panel, (T)annotation);
            }

            if (CenterMapOnSelectedAnnotation && annotation != null)
            {
                MapController.Instance.CenterMap(annotation.Coordinates);
            }
        }
        protected override void ConfigureSelectedLocationPanel(Panel panel, MapAnnotation <D> annotation)
        {
            var locationPanel = panel as SelectedLocationPanel;

            if (locationPanel)
            {
                DoubleRange range = null;

                if (ShouldSetPanelFence(annotation.Data, out range))
                {
                    locationPanel.SetButtonFence(range);
                }
            }

            base.ConfigureSelectedLocationPanel(panel, annotation);
        }
示例#14
0
        public void RemoveAnnotation(MapAnnotation annotation)
        {
            lock (m_toAdd)
            {
                m_toAdd.Remove(annotation);
            }

            if (annotation == SelectedAnnotation)
            {
                SelectAnnotation(null);
            }

            m_locationAnnotations.Remove(annotation.Location.Id, annotation);

            lock (m_toRemove)
            {
                m_toRemove.Add(annotation);
            }
        }
示例#15
0
        public void FocusAnnotation(MapAnnotation annotation, int range = 0)
        {
            var d1 = ForegroundPositionService.Instance.Position.GetDistanceFrom(annotation.Coordinates) * 3;

            // "magic number" : 150 is the closest we want to zoom
            var d = Math.Max(Math.Max(d1, range), 150);

            if (MapController.Instance.SelectedAnnotation == annotation)
            {
                MapController.Instance.PanZoomTo(annotation.Coordinates, new Vector {
                    X = d, Y = d
                }, .6f);
            }
            else
            {
                MapController.Instance.PanZoomTo(annotation, new Vector {
                    X = d, Y = d
                }, .6f);
            }
        }
示例#16
0
        protected void HandleLocationsUpdated(object sender, System.EventArgs e)
        {
            var oldSearchAnns = m_searchLocations;

            m_searchLocations = new Dictionary <string, MapAnnotation>();

            ThreadHelper.Instance.CallOnMainThread(() =>
            {
                foreach (var loc in LocationCache.Instance.Locations)
                {
                    if (!ShouldAddSearchLocationAnnotation(loc))
                    {
                        continue;
                    }

                    if (oldSearchAnns.ContainsKey(loc.Id))
                    {
                        // We already have this annotation,
                        // no need to re-add
                        var ann = oldSearchAnns[loc.Id];
                        oldSearchAnns.Remove(loc.Id);
                        m_searchLocations[loc.Id] = ann;
                    }
                    else
                    {
                        var ann = new MapAnnotation(loc);
                        m_searchLocations[loc.Id] = ann;

                        // When resolving markers, check location types first,
                        // then story tags.
                        if (loc.LocationTypes != null)
                        {
                            foreach (var t in loc.LocationTypes)
                            {
                                MediaElement marker = null;

                                if (m_locationTypeMarkers.TryGetValue(t, out marker))
                                {
                                    ann.Marker = marker;
                                    break;
                                }
                            }
                        }

                        if (ann.Marker == null && loc.StoryTags != null)
                        {
                            foreach (var s in loc.StoryTags)
                            {
                                MediaElement marker = null;

                                if (m_storyTagMarkers.TryGetValue(s, out marker))
                                {
                                    ann.Marker = marker;
                                    break;
                                }
                            }
                        }

                        AddAnnotation(ann);
                    }
                }

                // Any that are left in the old dictionary can be removed
                foreach (var ann in oldSearchAnns.Values)
                {
                    MapView.RemoveAnnotation(ann);
                }
            });
        }
示例#17
0
 public override AnnotationGameObject GetObjectForAnnotation(MapAnnotation annotation)
 {
     return(GetObjectForAnnotation(annotation as T));
 }
        public virtual void RemoveTaskAnnotation(D driver, MapAnnotation <D> ann)
        {
            m_taskAnnotations.Remove(driver.ActivationContext.InstanceId, ann);

            RemoveAnnotation(ann);
        }
        public virtual void AddTaskAnnotation(D driver, MapAnnotation <D> annotation)
        {
            m_taskAnnotations.Add(driver.ActivationContext.InstanceId, annotation);

            AddAnnotation(annotation);
        }