Пример #1
0
        public void AddMarkerMedia(ResourceActivationContext context, VisualMarkerMedia resource)
        {
            if (!CheckAdapter())
            {
                return;
            }

            if (resource.MediaElement == null ||
                resource.MediaElement.MediaUrl == null ||
                resource.Markers == null)
            {
                return;
            }

            foreach (var marker in resource.Markers.OfType <IVisualMarker>())
            {
                if (marker != null)
                {
                    var media = new MarkerMedia
                    {
                        ActivationContext = context,
                        Marker            = marker,
                        MediaLayout       = resource.MediaElement.Layout,
                        MediaType         = resource.MediaElement.MediaItem.MediaType,
                        MediaUrl          = resource.MediaElement.MediaUrl,
                        Color             = resource.MediaElement.Color,
                        ObjectId          = context.InstanceId,
                        OnOpen            = () =>
                        {
                            context.Open();
                        },
                        OnSelect = () =>
                        {
                            context.FireEvent("select");
                        },
                        OnClose = () =>
                        {
                            context.Close();
                        }
                    };

                    AddMarkerMedia(media);
                }
            }
        }
Пример #2
0
        internal void Add3DAsset(ResourceActivationContext context, VisualMarker3DAsset resource)
        {
            if (!CheckAdapter())
            {
                return;
            }

            if (resource.AssetInstance == null ||
                resource.Markers == null)
            {
                return;
            }

            foreach (var marker in resource.Markers)
            {
                var vumark = marker as IVisualMarker;

                if (vumark != null)
                {
                    var asset = new MarkerAsset
                    {
                        ActivationContext = context,
                        AssetInstance     = resource.AssetInstance,
                        Marker            = vumark,
                        MediaLayout       = resource.FallbackImage == null ? null : resource.FallbackImage.Layout,
                        MediaUrl          = resource.FallbackImage == null ? null : resource.FallbackImage.MediaUrl,
                        ObjectId          = context.InstanceId,
                        OnOpen            = () =>
                        {
                            context.Open();
                        },
                        OnSelect = () =>
                        {
                            context.FireEvent("select");
                        },
                        OnClose = () =>
                        {
                            context.Close();
                        }
                    };

                    Add3DAsset(asset);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Starts monitoring an attraction item by setting up a location fence and following
        /// the activation/range rules. Will call back "activate" and "deactivate" based
        /// on these rules.
        /// </summary>
        /// <param name="ctxt"></param>
        /// <param name="actxt"></param>
        /// <param name="item"></param>
        /// <param name="activateItems"></param>
        /// <param name="deactivateItems"></param>
        private void MonitorAttractionItem(
            ResourceActivationContext ctxt,
            ActivatedAttractionContext actxt,
            LocationAttractionItemProperties item,
            IAttractionItemHandler handler)
        {
            bool activated  = false;
            var  wasInRange = ctxt.CheckEvent("in_range");

            Func <bool> checkAutoplay = () =>
            {
                var didPlay = ctxt.CheckEvent("open");

                return(item.AutoplayBehavior == AttractionRangeAutoplayBehavior.Always ||
                       item.AutoplayBehavior == AttractionRangeAutoplayBehavior.Once && !didPlay);
            };

            var autoplay = checkAutoplay();

            if (item.RangeAvailability == AttractionRangeAvailability.Always)
            {
                // Always activate
                activated = true;
                handler.Activate(actxt.Attraction, autoplay);
            }
            else
            {
                if (wasInRange && item.RangeAvailability == AttractionRangeAvailability.InRangeAndAfter)
                {
                    handler.Activate(actxt.Attraction, autoplay);
                }
            }

            var range = item.Range ?? actxt.Range;

            if (range != null && actxt.Attraction.Locations != null)
            {
                m_fencePool.WatchLocations(ctxt.InstanceId, actxt.Attraction.Locations, range,
                                           (locations) =>
                {
                    ctxt.FireEvent("in_range");
                    ctxt.SetState("in_range");

                    // In Range
                    if (!activated || item.RangeAvailability == AttractionRangeAvailability.OnlyInRange)
                    {
                        activated = true;
                        handler.Activate(actxt.Attraction, checkAutoplay());
                    }
                },
                                           () =>
                {
                    ctxt.ClearState("in_range");

                    // Out of range
                    if (item.RangeAvailability == AttractionRangeAvailability.OnlyInRange)
                    {
                        handler.Deactivate(actxt.Attraction);
                    }
                });
            }
            else
            {
                // Items haven't been activated, but there's no range or locations.
                // In this case treat the items as "in range" and activate them.
                if (!activated)
                {
                    ctxt.FireEvent("in_range");
                    ctxt.SetState("in_range");

                    activated = true;
                    handler.Activate(actxt.Attraction, autoplay);
                }
            }
        }