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);
                }
            }
        }
        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 ActivateResource(ResourceActivationContext context, PlayerReward resource)
 {
     if (!context.IsClosed)
     {
         RewardManager.Instance.ActivatePlayerReward(resource);
         context.Close();
     }
 }
        public override void ActivateResource(ResourceActivationContext context, ObjectiveCompleter resource)
        {
            if (resource.Objective != null && !context.IsClosed)
            {
                TaskManager.Instance.CompleteObjective(resource.Objective);

                context.Close();
            }
        }
Exemplo n.º 5
0
        void ApplyObjectAction(string objectId, string action, bool oneShot)
        {
            if (objectId == null)
            {
                return;
            }

            ResourceActivationContext inspectorCtxt = m_inspectors.GetLastOrDefault(objectId);

            if (inspectorCtxt != null && inspectorCtxt.InstanceId != m_currInspectorId)
            {
                // There's an inspector that matches this object
                m_currAction      = action;
                m_currObjId       = objectId;
                m_isOneShotAction = oneShot;

                var inspector = inspectorCtxt.Resource as ObjectInspector;

                if (inspector.Content is ScreenMessage)
                {
                    var screenMsg = (ScreenMessage)inspector.Content;

                    var data = new ResourcePanelData <ScreenMessage>(inspectorCtxt, screenMsg);

                    // Set curr id here so that a "pop" doesn't clear it.
                    m_currInspectorId = inspectorCtxt.InstanceId;

                    Action onClose = () =>
                    {
                        inspectorCtxt.Close();

                        m_currInspectorId = null;

                        if (m_isOneShotAction)
                        {
                            EndObjectAction(objectId, action);
                        }
                    };

                    if (screenMsg.Responses != null && screenMsg.Responses.Length > 0)
                    {
                        m_currPanel = ScreenDialogPanel;

                        PanelManager.Instance.Push(ScreenDialogPanel, data, onClose);
                    }
                    else
                    {
                        m_currPanel = ScreenMessagePanel;

                        PanelManager.Instance.Push(ScreenMessagePanel, data, onClose);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public override void ActivateResource(ResourceActivationContext context, RecipeDeactivator resource)
        {
            if (!context.IsClosed)
            {
                if (resource.RecipeReferences != null)
                {
                    foreach (var r in resource.RecipeReferences)
                    {
                        ActivatedRecipeManager.Instance.DeactivateRecipe(r.ObjectId);
                    }
                }

                context.Close();
            }
        }
        public override void ActivateResource(ResourceActivationContext context, LocativeAudioContent resource)
        {
            if (LocativeAudioAnnotationHandler.Instance && resource.ShowOnMap)
            {
                LocativeAudioAnnotationHandler.Instance.AddLocativeAudio(context.InstanceId, resource);
            }

            LocativeAudioDriver.Instance.Activate(context.InstanceId, resource,
                                                  () =>
            {
                context.Open();
            },
                                                  (success) =>
            {
                context.Close();
            });
        }
Exemplo n.º 8
0
        public override void ActivateResource(ResourceActivationContext context, InventoryCollectibles resource)
        {
            if (!context.IsClosed)
            {
                // Add items to player's inventory
                if (resource.StartAtZero)
                {
                    Inventory.Instance.Set(resource.CollectibleCounts);
                }
                else
                {
                    Inventory.Instance.Add(resource.CollectibleCounts);
                }

                context.Close();
            }
        }
Exemplo n.º 9
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);
                }
            }
        }
Exemplo n.º 10
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);
                }
            }
        }
Exemplo n.º 11
0
        public override void ActivateResource(ResourceActivationContext context, SavePoint resource)
        {
            if (!context.IsClosed)
            {
                var time = context.Retrieve <string>();

                if (time == null)
                {
                    context.Store(DateTime.Now.ToString());

                    SavePointManager.Instance.ActivateSavePoint(context, resource);
                }

                context.Close();
            }

            base.ActivateResource(context, resource);
        }
Exemplo n.º 12
0
        public void Play(ResourceActivationContext ctxt, PlayableContentBatch playableBatch)
        {
            BatchContext playableContext = new BatchContext
            {
                ActivationContext = ctxt,
                Playables         = playableBatch.Playables
            };

            m_containers[ctxt.InstanceId] = playableContext;

            if (playableBatch.Playables != null && playableBatch.Playables.Length > 0)
            {
                PlayNextFromBatch(playableContext, playableBatch, 0);
            }
            else
            {
                ctxt.Close();
            }
        }