Ejemplo n.º 1
0
    protected override void Start()
    {
        base.Start();
        sound = GetComponent <AudioSource>();

        InteractableObjectGrabbed += new InteractableObjectEventHandler(OnObjectGrabbed);
        InteractableObjectUsed    += new InteractableObjectEventHandler(OnObjectUsed);
    }
Ejemplo n.º 2
0
    public int radius;  // Radius of effect

    protected virtual void Start()
    {
        if (Serializer.IsDeserializing)
        {
            return;
        }
        if (Serializer.IsLoading)
        {
            return;
        }
        spherePrefab                 = ReferenceManager.instance.spherePrefab;
        economyManager               = ReferenceManager.instance.economyManager;
        InteractableObjectGrabbed   += new InteractableObjectEventHandler(DoGrabStart);
        InteractableObjectUngrabbed += new InteractableObjectEventHandler(DoGrabEnd);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// When the dispenser is WaitingForGrab, it checks if the plug that it extended is grabbed. If it is, it extends the other plug on the same cord, releasing it into the world. It creates a new cord to replace that one.
        /// If there are no controllers in the area, then the plug retracts and the dispenser goes back to the Free state
        /// </summary>
        /// <returns></returns>
        private IEnumerator WaitingForGrab()
        {
            cord.gameObject.SetActive(true);
            StartCoroutine(ExtendPlug(primaryPlug, primaryPlugAttach, PlugStart.position + PlugStart.forward * ExtendDistance));

            while (state == State.WaitingForGrab)
            {
                if (primaryPlug.GetComponent <VRTK_InteractableObject>().IsGrabbed())
                {
                    Destroy(primaryPlugAttach);

                    InteractableObjectEventHandler destroyPlugAttach         = null;
                    VRTK_InteractableObject        secondaryPlugInteractable = secondaryPlug.GetComponent <VRTK_InteractableObject>();

                    destroyPlugAttach = (object sender, InteractableObjectEventArgs e) =>
                    {
                        Destroy(secondaryPlugAttach);
                        secondaryPlugInteractable.InteractableObjectGrabbed -= destroyPlugAttach;
                    };

                    secondaryPlugInteractable.InteractableObjectGrabbed += destroyPlugAttach;

                    StartCoroutine(ExtendPlug(secondaryPlug, secondaryPlugAttach, PlugConnectionPoint.position));
                    secondaryPlugAttach.transform.rotation *= Quaternion.AngleAxis(180.0f, Vector3.up);

                    GetComponent <SocketPlugReceptacle>().ForcePlugLockAndConnect(secondaryPlug);

                    CreateCord();
                    state = State.Blocked;
                }
                else if (nearbyControllers.Count == 0)
                {
                    StartCoroutine(RetractPlug(primaryPlug, primaryPlugAttach));
                    state = State.Free;
                }

                yield return(new WaitForEndOfFrame());
            }
        }
Ejemplo n.º 4
0
 protected override void Awake()
 {
     base.Awake();
     InteractableObjectGrabbed += new InteractableObjectEventHandler(ResetPosition);
 }