示例#1
0
 public override void ActivateResource(ResourceActivationContext context, WalletCurrency resource)
 {
     if (context.IsFirstActivation)
     {
         Wallet.Instance.Add(resource.CurrencyCounts);
     }
 }
示例#2
0
        public WorldObjectBehaviour AddWorldObject(ResourceActivationContext context, GameObject obj, GameObject animationTarget, GameObject rootObj = null)
        {
            context.Open();

            var worldObj = (rootObj ?? obj).AddComponent <WorldObjectBehaviour>();

            worldObj.AnimationTarget    = animationTarget;
            worldObj.InteractibleObject = obj;
            worldObj.WorldObject        = obj;
            worldObj.ActivationContext  = context;

            m_worldObjects.Add(context.InstanceId, worldObj);

            var effects = m_pendingEffects[context.InstanceId];

            m_pendingEffects.RemoveAll(context.InstanceId);

            if (effects != null)
            {
                foreach (var container in effects)
                {
                    ApplyEffects(worldObj, container.ActivationContext, container.Resource);
                }
            }

            return(worldObj);
        }
        public override void ActivateResource(ResourceActivationContext context, ScriptLauncher resource)
        {
            Action run = () =>
            {
                ScriptManager.Instance.LaunchScript(resource, context.FrameContext, context.InstanceId, (didClose) =>
                {
                    if (didClose)
                    {
                        context.Close();
                    }
                });
            };

            if (!context.IsClosed && resource.ScriptReference != null)
            {
                if (context.IsFirstActivation)
                {
                    ScriptManager.Instance.StopRunningScript(resource.ScriptReference.ObjectId, context.InstanceId, true, run);
                }
                else
                {
                    run();
                }
            }
        }
        public override void Play(ResourceActivationContext activationContext, PlayableContent playable, Action onClose = null)
        {
            if (playable.Content is LocalizedAudioContent)
            {
                QueueAudioContent(activationContext, playable, playable.Content as LocalizedAudioContent, onClose);
            }
            else if (playable.Content is LocativeAudioContent)
            {
                m_locativeAudioProcessor.ActivateResource(activationContext, playable.Content as LocativeAudioContent);
            }
            else if (IsScreenContent(playable))
            {
                QueueScreenContent(activationContext, playable, onClose);
            }
            else
            {
                m_logger.Warning("Unhandled content type {0} (playable.Id={1})",
                                 playable.Content != null ? playable.Content.Type : null,
                                 playable.Id);

                if (onClose != null)
                {
                    onClose();
                }
            }
        }
示例#5
0
 public AttractionItemHandler(ResourceActivationContext ctxt, R resource, I item)
 {
     this.ItemProperties    = resource;
     this.ActivationContext = ctxt;
     this.Resource          = resource;
     this.Item = item;
 }
示例#6
0
        private void ActivateAttraction(ResourceActivationContext ctxt, LocationAttractionActivator activator, LocationAttraction attraction)
        {
            ActivatedAttractionContext atctxt = null;

            if (!m_atrractionActivators.TryGetValue(attraction.Id, out atctxt))
            {
                atctxt = new ActivatedAttractionContext(attraction);

                m_atrractionActivators.Add(attraction.Id, atctxt);

                var annotation = new MapAnnotation <ActivatedAttractionContext>(attraction.Locations.First(), atctxt);

                AddAnnotation(attraction.Id, annotation);

                var handlers = m_attractionItemHandlers[attraction.Id];

                if (handlers != null)
                {
                    foreach (var handler in handlers)
                    {
                        AttachHandlerToAttraction(atctxt, handler);
                    }
                }
            }

            atctxt.AddActivator(ctxt, activator);
        }
示例#7
0
        void DeactivateAttractionItem(ResourceActivationContext context, LocationAttractionItemProperties item)
        {
            IAttractionItemHandler handler = null;

            if (m_itemHandlers.TryGetValue(context.InstanceId, out handler))
            {
                if (item.AttractionReferences != null)
                {
                    foreach (var a in item.AttractionReferences)
                    {
                        m_attractionItemHandlers.Remove(a.ObjectId, handler);

                        ActivatedAttractionContext actxt;

                        if (m_atrractionActivators.TryGetValue(a.ObjectId, out actxt))
                        {
                            DetachHandlerFromAttraction(actxt, handler);
                        }
                    }
                }

                // Clean up any leftovers
                handler.DeactivateAll();
            }
        }
示例#8
0
        void ApplyEffects(WorldObjectBehaviour worldObj, ResourceActivationContext effectContext, WorldObjectEffectPlayer resource)
        {
            if (resource.Effects != null)
            {
                foreach (var eref in resource.Effects)
                {
                    IWorldObjectEffectHandler handler;

                    if (m_effectHandlers.TryGetValue(eref.Type, out handler))
                    {
                        var appliedEffect = new AppliedEffect(handler, worldObj, effectContext, resource, eref);

                        handler.ApplyEffect(appliedEffect);

                        m_appliedEffects.Add(effectContext.InstanceId, appliedEffect);
                    }
                    else
                    {
                        var errStr = string.Format("Could not find handler for effect type {0}", eref.Type);

                        SystemErrorHandler.Instance.ReportError(errStr);

                        m_logger.Warning(errStr);
                    }
                }
            }
        }
示例#9
0
        public void Add3DAsset(ResourceActivationContext ctxt, IVisualMarker marker, string mediaId, AssetInstance assetInstance, string fallbackImageUrl = null, Layout layout = null, Action onOpen = null, Action onSelect = null)
        {
            if (!CheckAdapter())
            {
                return;
            }

            if (DoesObjectExist(marker.GetIdentifier(), mediaId))
            {
                return;
            }

            var markerAsset = new MarkerAsset
            {
                ActivationContext = ctxt,
                AssetInstance     = assetInstance,
                Marker            = marker,
                MediaType         = MediaType.Image,
                MediaUrl          = fallbackImageUrl,
                MediaLayout       = layout,
                ObjectId          = mediaId,
                OnSelect          = onSelect,
                OnOpen            = onOpen
            };

            Add3DAsset(markerAsset);
        }
示例#10
0
        public override void UpdateResource(ResourceActivationContext context, LocationMarker resource)
        {
            DeactivateResource(context, resource);
            ActivateResource(context, resource);

            base.UpdateResource(context, resource);
        }
示例#11
0
        public void ActivateInspector(ResourceActivationContext context, ObjectInspector inspector)
        {
            if (inspector.TargetReferences != null)
            {
                string targetId     = null;
                string targetAction = null;

                foreach (var reference in inspector.TargetReferences)
                {
                    var id = context.GetInstanceId(reference.ObjectId);

                    if (targetId == null && m_objectActions.GetCount(id) > 0)
                    {
                        // TODO: inspectors should define this action
                        targetAction = m_objectActions[id].First();
                        targetId     = id;
                    }

                    m_inspectors.Add(id, context);
                }

                // No current object or current object is the same as targetId
                if (targetId != null)
                {
                    if (m_currObjId == null ||
                        m_currObjId == targetId)
                    {
                        // Actions stored in m_objectActions are never one-shot
                        ApplyObjectAction(targetId, targetAction, false);
                    }
                }
            }
        }
示例#12
0
 public override void ActivateResource(ResourceActivationContext context, WalletCurrencyLimit resource)
 {
     if (context.IsFirstActivation)
     {
         Wallet.Instance.SetLimits(resource);
     }
 }
 public override void ActivateResource(ResourceActivationContext context, InventoryCollectibleLimit resource)
 {
     if (context.IsFirstActivation)
     {
         Inventory.Instance.SetLimits(resource);
     }
 }
示例#14
0
        public void ApplyEffects(ResourceActivationContext context, WorldObjectEffectPlayer resource)
        {
            if (resource.WorldObjectReferences != null &&
                resource.Effects != null)
            {
                foreach (var wo in resource.WorldObjectReferences)
                {
                    var instId = context.GetInstanceId(wo.ObjectId);

                    var worldObjs = m_worldObjects[instId];

                    if (worldObjs != null)
                    {
                        foreach (var worldObj in worldObjs)
                        {
                            ApplyEffects(worldObj, context, resource);
                        }
                    }
                    else
                    {
                        m_pendingEffects.Add(instId, new ActiveResourceContainer <WorldObjectEffectPlayer>(context, resource));
                    }
                }
            }
        }
示例#15
0
        void AddSpawnedAsset(ResourceActivationContext context, AssetSpawner resource, UnityAsset asset, GameObject obj)
        {
            GameObject rootObject = new GameObject(asset.AssetName);

            rootObject.transform.position   = Vector3.zero;
            rootObject.transform.localScale = Vector3.one;
            rootObject.transform.rotation   = Quaternion.Euler(Vector3.zero);

            var worldObj = AddWorldObject(context, obj, rootObject);

            worldObj.Asset = asset;

            obj.transform.position   = Vector3.zero;
            obj.transform.localScale = Vector3.one;
            obj.transform.rotation   = Quaternion.Euler(Vector3.zero);

            obj.transform.SetParent(rootObject.transform);

            if (resource.SpawnPosition is FixedWorldPosition)
            {
                var fixedPos = resource.SpawnPosition as FixedWorldPosition;

                if (fixedPos.Position != null)
                {
                    rootObject.transform.position = LayoutHelper.ToVector3(fixedPos.Position);
                }

                if (resource.AssetInstance.Layout != null)
                {
                    LayoutHelper.Apply(obj.transform, resource.AssetInstance.Layout);
                }
            }

            m_objectsById[resource.AssetInstance.Id] = worldObj;
        }
示例#16
0
        public void RemoveEffects(ResourceActivationContext context, WorldObjectEffectPlayer resource)
        {
            if (m_effects.ContainsKey(context.InstanceId))
            {
                var effects = m_effects[context.InstanceId];

                if (effects != null)
                {
                    foreach (var effect in effects)
                    {
                        GameObject.Destroy(effect);
                    }
                }
            }

            if (resource.WorldObjectReferences != null)
            {
                foreach (var objRef in resource.WorldObjectReferences)
                {
                    var instId = context.GetInstanceId(objRef.ObjectId);

                    m_pendingEffects.RemoveAll(instId);
                }
            }

            m_effects.RemoveAll(context.InstanceId);
        }
示例#17
0
        void ApplyEffects(WorldObjectBehaviour worldObj, ResourceActivationContext effectContext, WorldObjectEffectPlayer resource)
        {
            if (resource.Effects != null)
            {
                foreach (var eref in resource.Effects)
                {
                    switch (eref.Type)
                    {
                    case "motive.unity.animation":

                        var anim = eref as UnityAnimation;

                        if (anim != null)
                        {
                            var asset = anim.Asset;

                            if (asset != null)
                            {
                                var animTgt = worldObj.GetAnimationTarget();

                                if (animTgt)
                                {
                                    // Target may have been destroyed somewhere
                                    var objAnim = worldObj.GetAnimationTarget().AddComponent <WorldObjectAnimation>();
                                    objAnim.AnimationAsset = asset;

                                    m_effects.Add(effectContext.InstanceId, objAnim);
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
        public void ProcessInterfaceDirector(ResourceActivationContext context, InterfaceDirector director)
        {
            if (context.IsClosed)
            {
                return;
            }

            context.Open();

            if (director.Commands == null ||
                director.Commands.Length == 0)
            {
                context.Close();

                return;
            }

            BatchProcessor iter = new BatchProcessor(director.Commands.Length, context.Close);

            foreach (var command in director.Commands)
            {
                IInterfaceCommandHandler handler = null;

                if (m_handlers.TryGetValue(command.Type, out handler))
                {
                    handler.ProcessInterfaceCommand(context, command, () => iter++);
                }
                else
                {
                    throw new NotSupportedException("Unsupported interface command type " + command.Type);
                }
            }
        }
示例#19
0
        public void SpawnAsset(ResourceActivationContext context, AssetSpawner resource)
        {
            if (resource.AssetInstance == null ||
                resource.AssetInstance.Asset == null)
            {
                return;
            }

            var asset = resource.AssetInstance.Asset as UnityAsset;

            if (asset != null)
            {
                if (asset.AssetBundle != null)
                {
                    AssetLoader.LoadAsset <GameObject>(asset, obj =>
                    {
                        if (obj)
                        {
                            AddSpawnedAsset(context, resource, asset, obj);
                        }
                    });
                }
                else
                {
                    var obj = Resources.Load <GameObject>(asset.AssetName);

                    if (obj)
                    {
                        AddSpawnedAsset(context, resource, asset, GameObject.Instantiate(obj));
                    }
                }
            }

            context.Open();
        }
示例#20
0
        public void AddMarkerImage(ResourceActivationContext ctxt, IVisualMarker marker, string mediaId, string url, Layout layout = null, Action onOpen = null, Action onSelect = null)
        {
            if (!CheckAdapter())
            {
                return;
            }

            if (DoesObjectExist(marker.GetIdentifier(), mediaId))
            {
                return;
            }

            var markerMedia = new MarkerMedia
            {
                ActivationContext = ctxt,
                Marker            = marker,
                MediaType         = MediaType.Image,
                MediaUrl          = url,
                MediaLayout       = layout,
                ObjectId          = mediaId,
                OnSelect          = onSelect,
                OnOpen            = onOpen
            };

            AddMarkerMedia(markerMedia);
        }
示例#21
0
 public override void DeactivateResource(ResourceActivationContext context, LocationAugmentedImage resource)
 {
     if (ARWorld.Instance)
     {
         ARWorld.Instance.RemoveLocationAugmentedImage(context, resource);
     }
 }
示例#22
0
 public override void ActivateResource(ResourceActivationContext context, PlayableContentBatch resource)
 {
     if (!context.IsClosed)
     {
         PlayableContentHandler.Instance.Play(context, resource);
     }
 }
示例#23
0
        public void ActivateContent(ResourceActivationContext context, LocationAttractionContent resource)
        {
            var handler = new PlayableContentAttractionItemHandler(context, resource);

            ActivateItemHandler(handler);

            OnUpdate();
        }
示例#24
0
 public AppliedEffect(IWorldObjectEffectHandler handler, WorldObjectBehaviour worldObject, ResourceActivationContext activationContext, WorldObjectEffectPlayer effectPlayer, IScriptObject effect)
 {
     Handler           = handler;
     WorldObject       = worldObject;
     ActivationContext = activationContext;
     EffectPlayer      = effectPlayer;
     Effect            = effect;
 }
 public override void ActivateResource(ResourceActivationContext context, PlayerReward resource)
 {
     if (!context.IsClosed)
     {
         RewardManager.Instance.ActivatePlayerReward(resource);
         context.Close();
     }
 }
 public LocationValuablesCollectionManagerEventArgs(ResourceActivationContext ctxt, LocationValuablesCollection lvc, bool resetState = false)
 {
     this.ResetState   = resetState;
     LocationValuables = new LocationValuablesCollectionItemContainer[]
     {
         new LocationValuablesCollectionItemContainer(ctxt, lvc)
     };
 }
        protected virtual void PlayNotification(ResourceActivationContext context, PlayableContent playable, Notification notification, ResourcePanelData <Notification> data, Action onClose)
        {
            if (Platform.Instance.IsInBackground)
            {
                context.Open();

                if (!BackgroundNotifier.Instance.HasNotification(context.InstanceId))
                {
                    var localNotification = new Motive.Core.Notifications.LocalNotification();

                    localNotification.Title = notification.Title;
                    localNotification.Text  = notification.Message;

                    Platform.Instance.LocalNotificationManager.PostNotification(playable.Id, localNotification);
                }

                BackgroundNotifier.Instance.RemoveNotification(context.InstanceId);

                /*
                 * if (notification.SoundUrl != null)
                 * {
                 *  var path = WebServices.Instance.MediaDownloadManager.GetPathForItem(notification.SoundUrl);
                 *  m_channel.Play(new Uri(path));
                 * }*/

                if (onClose != null)
                {
                    onClose();
                }
            }
            else
            {
                if (notification.Title != null ||
                    notification.Message != null)
                {
                    Push(context, PanelStack, NotificationPanel, data, onClose);
                }
                else
                {
                    context.Open();

                    if (notification.Vibrate)
                    {
                        Platform.Instance.LocalNotificationManager.Vibrate();
                    }

                    if (notification.Sound != null)
                    {
                        Platform.Instance.PlaySound(notification.Sound.Url);
                    }

                    if (onClose != null)
                    {
                        onClose();
                    }
                }
            }
        }
示例#28
0
        public void DeactivateAssignment(ResourceActivationContext context, Assignment assignment)
        {
            m_assignments.Remove(context.InstanceId);

            if (Updated != null)
            {
                Updated(this, EventArgs.Empty);
            }
        }
        public override void DeactivateResource(ResourceActivationContext context, LocativeAudioContent resource)
        {
            if (LocativeAudioAnnotationHandler.Instance && resource.ShowOnMap)
            {
                LocativeAudioAnnotationHandler.Instance.RemoveLocativeAudio(context.InstanceId);
            }

            LocativeAudioDriver.Instance.Deactivate(context.InstanceId, resource);
        }
示例#30
0
        public override void DeactivateResource(ResourceActivationContext context, LocationMarker resource)
        {
            if (MapMarkerAnnotationHandler.Instance)
            {
                MapMarkerAnnotationHandler.Instance.RemoveLocationMarker(context.InstanceId);
            }

            base.DeactivateResource(context, resource);
        }