コード例 #1
0
        /// <summary>
        /// Creates a full interactive object including interactions, conditions... By using
        /// S_IODefinition as an argument
        /// NOTE :This method can be only be called from the SpatialStories API.
        /// </summary>
        /// <param name="_definition">An interactive object definition</param>
        /// <param name="_wireDependencies"> Do the dependencies will be wired now ? (set that to false if you have circular dependencies that need
        /// to be post processed when all the ios and interactions have been created) </param>
        /// <returns>An interactive object ready to use</returns>
        internal static Gaze_InteractiveObject CreateInteractiveObject(S_IODefinition _definition, bool _wireDependencies)
        {
            // Create the interactive object from the prefab
            GameObject ioGameObject = GameObject.Instantiate(Resources.Load("Interactive Object") as GameObject);

            // Add the GUID to the io in order to be able to identify it between platforms and executions
            ioGameObject.AddComponent <S_Guid>().SetGUID(_definition.GUID);

            // Begin the crafting process
            ioGameObject.name = _definition.Name + " (IO)";
            ioGameObject.transform.position   = _definition.Position;
            ioGameObject.transform.rotation   = _definition.Rotation;
            ioGameObject.transform.localScale = _definition.Scale;

            // Create the interactions once the IO is ready
            Gaze_InteractiveObject io = ioGameObject.GetComponent <Gaze_InteractiveObject>();

            // If some visuals where specified add them to the new game object.
            if (_definition.Visuals != null)
            {
                AddNestedVisuals(_definition.Visuals, io);
            }

            CreateInteractionsForGameObject(_definition, io, _wireDependencies);

            return(io);
        }
コード例 #2
0
        /// <summary>
        /// Creates all the interactions specified in the IO definition and binds them into the
        /// newly created Interactive Object
        /// </summary>
        /// <param name="_ioDef"> The definition of the IO in process of creation </param>
        /// <param name="_io"> The instance of the interactive object being created </param>
        /// <param name="_wireDependencies"> Do the dependencies will be wired now ? (set that to false if you have circular dependencies that need
        /// to be post processed when all the ios and interactions have been created) </param>
        private static void CreateInteractionsForGameObject(S_IODefinition _ioDef, Gaze_InteractiveObject _io, bool _wireDependencies)
        {
            // Get the base interaction in order to replicate it as many times as needed
            Gaze_Interaction modelInteraction = _io.GetComponentInChildren <Gaze_Interaction>();

            // Create all the interactions specified on the io definition
            int numInteractions = _ioDef.Interactions.Count;

            for (int i = 0; i < numInteractions; i++)
            {
                // Create a new copy of the model interation and parent it to the interactions of the io
                GameObject interaction = GameObject.Instantiate(modelInteraction.gameObject, modelInteraction.transform.parent);

                // Get the interaction definition
                S_InteractionDefinition interDef = _ioDef.Interactions[i];

                // Add a GUID in order to identify in a unique way across all the apps and runtimes
                interaction.AddComponent <S_Guid>().SetGUID(interDef.GUID);

                // Set the interaction name
                interaction.name = interDef.Name;

                // Create the interaction conditions
                CreateConditionsForInteraction(interDef, interaction);

                // Create the interaction Actions
                CreateActionsForInteraction(interDef, interaction);

                // Add the Delay to the interaction
                if (interDef.Delay > 0)
                {
                    Gaze_Conditions cond = interaction.GetComponent <Gaze_Conditions>();
                    cond.delayed       = true;
                    cond.delayDuration = interDef.Delay;
                }

                // Destroy the game object used to hold the monobehaivours before
                // the creation of the interaction
                interDef.DestroyComponentHolder();


                // Create the interaction dependencies if necessary
                if (_wireDependencies)
                {
                    CreateDependenciesForInteraction(interDef, interaction);
                }
                else
                {
                    depenenciesToWire.Add(new KeyValuePair <GameObject, S_InteractionDefinition>(interaction, interDef));
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Creates a new Interactive Object using the definition.
 /// </summary>
 /// <param name="_definition">Definition of the game object to create</param>
 /// <param name="_wireDependencies"> Do the dependencies will be wired now or are you going to call WirePendingDependencies? (set that to false if you have circular dependencies that need
 /// to be post processed when all the ios and interactions have been created) </param>
 /// <returns></returns>
 public static Gaze_InteractiveObject CreateInteractiveObject(S_IODefinition _definition, bool _wireDependencies = true)
 {
     return(SpatialStoriesFactory.CreateInteractiveObject(_definition, _wireDependencies));
 }