public override void SetupUsingApi(GameObject _interaction)
        {
            // Get the data and cast it
            string objectToGazeGUID = creationData[0].ToString();
            bool   gazeIn           = (bool)creationData[1];
            Gaze_GazeConstraints gazeConstraints = (Gaze_GazeConstraints)creationData[2];

            // Get the conditions obj
            Gaze_Conditions conditions = _interaction.GetComponent <Gaze_Conditions>();

            // Set al the necessary parameters
            conditions.gazeEnabled          = true;
            conditions.gazeIn               = gazeIn;
            constraints                     = gazeConstraints;
            conditions.gazeConstraintsIndex = (int)gazeConstraints;
            conditions.gazeStateIndex       = gazeIn ? (int)Gaze_HoverStates.IN : (int)Gaze_HoverStates.OUT;


            if (gazeConstraints == Gaze_GazeConstraints.OBJECT)
            {
                Gaze_InteractiveObject io = SpatialStoriesAPI.GetInteractiveObjectWithGUID(objectToGazeGUID);
                conditions.gazeColliderIO = io;
                // Setup the gaze collider
                Setup(io.GetComponentInChildren <Gaze_Gaze>().GetComponent <Collider>());
            }
            else
            {
                // Setup the gaze collider
                conditions.gazeColliderIO = conditions.RootIO;
                Setup(conditions.RootIO.GetComponentInChildren <Gaze_Gaze>().GetComponent <Collider>());
            }
        }
Ejemplo n.º 2
0
        public override void OnEnable()
        {
            base.OnEnable();
            IO            = GetIO();
            visualsScript = IO.GetComponentInChildren <Gaze_InteractiveObjectVisuals>();
            //Gaze_EventManager.OnGazeEvent += OnGazeEvent;

            if (loopAudio.Length < 5)
            {
                loopAudio = new LOOP_MODES[5];
            }
        }
Ejemplo n.º 3
0
        private void SetupConditionsToCheck()
        {
            activeConditions.Clear();

            if (gazeEnabled)
            {
                activeConditions.Add(new Gaze_GazeCondition(this, gazeColliderIO.GetComponentInChildren <Gaze_Gaze>().GetComponent <Collider>(), (Gaze_GazeConstraints)gazeConstraintsIndex));
            }

            if (proximityEnabled)
            {
                activeConditions.Add(new Gaze_ProximityCondition(this));
            }

            if (arkitTouchEnabled)
            {
                activeConditions.Add(new Gaze_ARKitScreenTouchCondition(this, touchColliderIO, arkitTouchOption == ARKIT_TOUCH_OPTIONS.Object));
            }
        }
        /// <summary>
        /// Checks the proximities conditions validity.
        /// </summary>
        /// <returns><c>true</c>, if proximities was checked, <c>false</c> otherwise.</returns>
        /// <param name="e">E.</param>
        private bool HandleProximity(Gaze_ProximityEventArgs e)
        {
            // get colliding objects
            Gaze_InteractiveObject sender = ((Gaze_InteractiveObject)e.Sender).GetComponentInChildren <Gaze_Proximity>().IOScript;
            Gaze_InteractiveObject other  = ((Gaze_InteractiveObject)e.Other).GetComponentInChildren <Gaze_Proximity>().IOScript;
            // make sure the collision concerns two objects in the list of proximities (-1 if NOT)

            int otherIndex = IsCollidingObjectsInList(other, sender);

            //				Debug.Log ("otherIndex = " + otherIndex);
            if (otherIndex != -1)
            {
                // OnEnter and tested only if validation is not already true (to avoid multiple collision to toggle the proximitiesValidated flag
                if (e.IsInProximity && !IsValid)
                {
                    // update number of collision in the list occuring
                    collisionsOccuringCount++;
                    // if the sender is normal entry, add colliding object to it
                    if (otherIndex > -1)
                    {
                        gazeConditionsScript.proximityMap.AddCollidingObjectToEntry(gazeConditionsScript.proximityMap.proximityEntryList[otherIndex], sender.GetComponentInChildren <Gaze_Proximity>().IOScript);
                    }
                    // if the sender is an entryGroup (then otherIndex starts at -2 and goes down instead of going up), add colliding object to the entry of the group that triggered the event
                    else
                    {
                        gazeConditionsScript.proximityMap.AddCollidingObjectToEntry(gazeConditionsScript.proximityMap.proximityEntryGroupList[-otherIndex - 2].proximityEntries[entryInGroupIndex], sender.GetComponentInChildren <Gaze_Proximity>().IOScript);
                    }


                    if (gazeConditionsScript.proximityMap.proximityStateIndex.Equals((int)ProximityEventsAndStates.OnEnter) ||
                        gazeConditionsScript.proximityMap.proximityStateIndex.Equals((int)ProximityEventsAndStates.OnStay))
                    {
                        // get number of valid entries
                        int validatedEntriesCount = gazeConditionsScript.proximityMap.GetValidatedEntriesCount();
                        // OnEnter + RequireAll
                        if (gazeConditionsScript.requireAllProximities)
                        {
                            return(validatedEntriesCount == gazeConditionsScript.proximityMap.proximityEntryList.Count + gazeConditionsScript.proximityMap.proximityEntryGroupList.Count);
                        }
                        // OnEnter + NOT RequireAll
                        if (!gazeConditionsScript.requireAllProximities)
                        {
                            return(validatedEntriesCount >= 2);
                        }
                    }
                }

                // OnExit
                else if (!e.IsInProximity)
                {
                    // update number of collision in the list occuring
                    collisionsOccuringCount--;
                    // update everyoneIsColliding tag before removing an element
                    gazeConditionsScript.proximityMap.UpdateEveryoneColliding();
                    if (otherIndex > -1)
                    {
                        // // if the sender is normal entry, remove colliding object to it
                        gazeConditionsScript.proximityMap.RemoveCollidingObjectToEntry(gazeConditionsScript.proximityMap.proximityEntryList[otherIndex], sender.GetComponentInChildren <Gaze_Proximity>().IOScript);
                    }
                    else
                    {
                        // if the sender is an entryGroup (then otherIndex starts at -2 and goes down instead of going up), remove colliding object to the entry of the group that triggered the event
                        gazeConditionsScript.proximityMap.RemoveCollidingObjectToEntry(gazeConditionsScript.proximityMap.proximityEntryGroupList[-otherIndex - 2].proximityEntries[entryInGroupIndex], sender.GetComponentInChildren <Gaze_Proximity>().IOScript);
                    }

                    // if proximity condition is EXIT
                    if (gazeConditionsScript.proximityMap.proximityStateIndex.Equals((int)ProximityEventsAndStates.OnExit))
                    {
                        if (gazeConditionsScript.requireAllProximities)
                        {
                            // every entry was colliding before the exit
                            if (gazeConditionsScript.proximityMap.IsEveryoneColliding)
                            {
                                IsValid = true;
                            }
                            else
                            {
                                IsValid = false;
                            }
                            // OnExit + NOT RequireAll
                        }
                        else
                        {
                            gazeConditionsScript.proximityMap.ResetEveryoneColliding();
                            IsValid = true;
                        }
                        // if proximity condition is ENTER
                    }
                    else
                    {
                        // if proximities was validated
                        if (IsValid)
                        {
                            // and if require all
                            if (gazeConditionsScript.requireAllProximities)
                            {
                                return(false);
                            }
                            else
                            {
                                // check there's a valid collision left in the list...
                                if (collisionsOccuringCount > 0)
                                {
                                    IsValid = true;
                                }
                                else
                                {
                                    IsValid = false;
                                }
                            }
                        }
                    }
                }
            }
            return(IsValid);
        }