/// <summary>
 /// Called when a valid object enters the collider for the InteractionArea.
 /// </summary>
 /// <param name="e">The event arguments that holds a reference to the InteractableObject.</param>
 public virtual void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
 {
     if (ObjectEnteredInteractionArea != null)
     {
         ObjectEnteredInteractionArea(this, e);
     }
 }
Exemplo n.º 2
0
        private void ChildEnterInteractionArea(object sender, InteractionAreaEventArgs interactionEvent)
        {
            checkInsideCylinder = true;

            InteractionArea area = sender as InteractionArea;

            interactableObject = interactionEvent.interactionObject;

            // Keep track of which child you're on
            completionCount = area.transform.GetSiblingIndex();
            pointToCheck    = interactableObject.transform.Find("Point");

            // Start condition - Only want to send this once on the first visit
            if (completionCount == 0)
            {
                MoveToNextCylinder();

                OnObjectUsedInteractionArea(SetInteractionAreaEvent(interactableObject));
            }
            // End condition - Last IA in the children was reached
            else if (completionCount == childrenAreas.Count - 1)
            {
                checkInsideCylinder = false;

                StartState();

                OnObjectFinishedInteractionArea(SetInteractionAreaEvent(interactableObject));
            }
            else
            {
                MoveToNextCylinder();
            }
        }
        protected void ChildInteractionFinished(object o, InteractionAreaEventArgs e)
        {
            int childIndex = (o as InteractionArea).transform.GetSiblingIndex();

            childrenAreas[childIndex].ObjectFinishedInteractionArea -= ChildInteractionFinished;

            // Disable the collider on the interaction area so no one else can hit it
            Collider childCollider = childrenAreas[childIndex].gameObject.GetComponent <Collider>();

            if (childCollider != null)
            {
                childCollider.enabled = false;
            }

            completionCount++;

            if (completionCount == childrenAreas.Count)
            {
                OnObjectFinishedInteractionArea(SetInteractionAreaEvent(gameObject));
            }
            else if (enforceOrder)
            {
                SwitchChildren(completionCount);
            }
        }
        public virtual void OnObjectInterruptInteractionArea(InteractionAreaEventArgs e)
        {
            interactionStarted = false;

            if (ObjectInterruptInteractionArea != null)
            {
                ObjectInterruptInteractionArea(this, e);
            }
        }
        /// <summary>
        /// Called when the interaction event has started in the InteractionArea.
        /// </summary>
        /// <param name="e">The event arguments that holds a reference to the InteractableObject.</param>
        public virtual void OnObjectUsedInteractionArea(InteractionAreaEventArgs e)
        {
            interactionStarted = true;

            if (ObjectUsedInteractionArea != null)
            {
                ObjectUsedInteractionArea(this, e);
            }
        }
        public override void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectEnteredInteractionArea(e);

            if (currentInteractionObject != null && e.interactionObject == currentInteractionObject.gameObject)
            {
                InteractionEnter(currentInteractionObject.gameObject);
            }
        }
Exemplo n.º 7
0
        public override void OnObjectEnteredInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectEnteredInteractionArea(e);

            if (currentInteractionObject != null)
            {
                // Get the starting directions to go off of
                previousFrameForwardDirection = currentInteractionObject.transform.forward;
                previousFrameRightDirection   = currentInteractionObject.transform.right;

                isTurnable = true;
            }
        }
        /// <summary>
        /// Sets the given GameObject and returns the Arguments for an InteractableEvent. This method should be
        /// called whenever using one of the 'On' Event Handleing methods.
        /// </summary>
        /// <param name="interactableObject">The GameObject that is triggering the event in the InteractionArea.</param>
        /// <returns></returns>
        public static InteractionAreaEventArgs SetInteractionAreaEvent(GameObject interactableObject)
        {
            VRTK_InteractableObject ioCheck = interactableObject.GetComponent <VRTK_InteractableObject>();
            bool interactableHasExtraArgs   = false;

            if (ioCheck != null)
            {
                interactableHasExtraArgs = ioCheck.HasExtraEventArgs;
            }

            InteractionAreaEventArgs e = new InteractionAreaEventArgs
            {
                interactionObject   = interactableObject,
                hasMoreReactionInfo = interactableHasExtraArgs
            };

            return(e);
        }
        public override void OnObjectExitedInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectExitedInteractionArea(e);

            InteractionExit(e.interactionObject);
        }
 private void ObjectFinishedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectFinishedInteraction.Invoke(o, e);
 }
 private void ObjectUnusedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectInterruptInteraction.Invoke(o, e);
 }
 private void ObjectUsedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectStartInteraction.Invoke(o, e);
 }
 private void ObjectExitedInteractionArea(object o, InteractionAreaEventArgs e)
 {
     OnObjectExitedInteractionArea.Invoke(o, e);
 }
Exemplo n.º 14
0
        public override void OnObjectExitedInteractionArea(InteractionAreaEventArgs e)
        {
            base.OnObjectExitedInteractionArea(e);

            isTurnable = false;
        }