Beispiel #1
0
 public void ReleaseBroomRight()
 {
     if (Game_Manager.instance.RightGrab.GetGrabbedObject() != null && Game_Manager.instance.RightGrab.GetGrabbedObject() == gameObject && !beingReleased)
     {
         beingReleased = true;
         Debug.Log("released");
         PlierZone.ForceUnsnap();
         BroomCollider1.enabled  = false;
         BroomCollider2.enabled  = false;
         BroomCollider3.enabled  = false;
         BroomCollider4.enabled  = false;
         BroomCollider5.enabled  = false;
         BroomCollider6.enabled  = false;
         BroomCollider7.enabled  = false;
         BroomCollider8.enabled  = false;
         PliersBody.centerOfMass = ProperMass;
         //foreach (MeshCollider col in gameObject.GetComponentsInChildren<MeshCollider>())
         //{
         //    col.enabled = false;
         //}
         if (Broom != null)
         {
             foreach (MeshCollider col in Broom.GetComponentsInChildren <MeshCollider>())
             {
                 col.enabled = true;
             }
         }
         StartCoroutine("WaitForRelease");
     }
 }
Beispiel #2
0
    IEnumerator BroomBreaks()
    {
        yield return(new WaitForSecondsRealtime(1f));

        BroomBreaksSound.Play();
        BroomPosition = transform.TransformPoint(GameObject.Find("BroomInTheJanitorAnimationBroom2").transform.localPosition);
        SwitchSnap.GetCurrentSnappedInteractableObject().transform.position = BroomPosition;
        SwitchSnap.GetCurrentSnappedInteractableObject().transform.TransformPoint(GameObject.Find("BroomInTheJanitorAnimationBroom2").transform.localRotation.eulerAngles);
        foreach (MeshRenderer child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <MeshRenderer>())
        {
            child.enabled = true;
        }
        foreach (Collider child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <Collider>())
        {
            child.enabled = true;
        }
        foreach (Transform child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <Transform>())
        {
            child.gameObject.AddComponent <Rigidbody>();
            child.gameObject.AddComponent <VRTK_InteractableObject>();
            child.gameObject.AddComponent <VRTK_FixedJointGrabAttach>();
            child.gameObject.AddComponent <VRTK_SwapControllerGrabAction>();
            child.GetComponent <VRTK_InteractableObject>().grabAttachMechanicScript  = child.gameObject.GetComponent <VRTK_FixedJointGrabAttach>();
            child.GetComponent <VRTK_InteractableObject>().secondaryGrabActionScript = child.gameObject.GetComponent <VRTK_SwapControllerGrabAction>();
            child.GetComponent <VRTK_InteractableObject>().holdButtonToGrab          = true;
            child.GetComponent <VRTK_InteractableObject>().isGrabbable                = true;
            child.gameObject.GetComponent <VRTK_FixedJointGrabAttach>().breakForce    = 10000;
            child.gameObject.GetComponent <VRTK_FixedJointGrabAttach>().precisionGrab = true;
            child.gameObject.tag = "BrokenBroom";
            child.parent         = null;
        }
        SwitchAnim.SetBool("Break", false);
        SwitchSnap.ForceUnsnap();
        notWaited = true;
    }
Beispiel #3
0
 private void ApplyState()
 {
     if (dropZoneNetRef == NetworkReference.INVALID)
     {
         if (io.IsInSnapDropZone())
         {
             dropZone.ForceUnsnap();
             dropZone = null;
         }
     }
     else
     {
         GameObject dzobj = dropZoneNetRef.FindObject();
         if (dzobj != null)
         {
             VRTK_SnapDropZone newDropZone = dzobj.GetComponent <VRTK_SnapDropZone>();
             if (newDropZone != null)
             {
                 if (newDropZone != dropZone)
                 {
                     if (dropZone != null)
                     {
                         dropZone.ForceUnsnap();
                     }
                     newDropZone.ForceSnap(io.gameObject);
                     dropZone = newDropZone;
                 }
             }
             else
             {
                 Debug.LogError("DropZoneNetRef doesn't have a VRTK_SnapDropZone: " + dropZoneNetRef);
             }
         }
         else
         {
             Debug.LogError("Couldn't find DropZoneNetRef: " + dropZoneNetRef);
         }
     }
 }
 private void Update()
 {
     if (OpenBoxSnap.GetCurrentSnappedObject() != null && OpenBoxSnap.GetCurrentSnappedObject() ==
         Marker && MarkerReleaseButton.AtMaxLimit() && MarkerReleaseButton.stayPressed)
     {
         Game_Manager.instance.beingUnSnapped = true;
         OpenBoxSnap.ForceUnsnap();
         if (markerCanSnap)
         {
             markerCanSnap = false;
             StartCoroutine("WaitForMarker");
         }
     }
 }
Beispiel #5
0
    // Called when an object is snapped in
    public void OnSnap(object sender, SnapDropZoneEventArgs e)
    {
        Plug snappedPlug = e.snappedObject.GetComponent <Plug>();

        if (!snappedPlug)
        {
            Debug.LogError("Snapped obj not a plug");
            return;
        }
        // Try to plug it in
        if (!PlugIn(snappedPlug))
        {
            Debug.LogError("Unable to snap plug in");
            _snapDropZone.ForceUnsnap();
        }
    }
Beispiel #6
0
    public void UnLoadMagazine()
    {
        if (attachedMag)
        {
            magWell.ForceUnsnap();

            Rigidbody magBody = attachedMag.GetComponent <Rigidbody>();
            Collider  magCol  = attachedMag.GetComponent <Collider>();
            magBody.useGravity  = true;
            magBody.isKinematic = false;
            magCol.isTrigger    = false;

            attachedMag.isGrabbable = true;

            attachedMag = null;
        }
    }
Beispiel #7
0
 public void Press()
 {
     if (isShellCasingSnapped)
     {
         // Fire the shell!
         shellCasing.GetComponent <ShellCasing>().Fire(instanceShellEmitter);
         compSnapZone.ForceUnsnap();
         isShellCasingSnapped = false;
     }
     else
     {
         if (soundFailure != null)
         {
             compAudio.PlayOneShot(soundFailure);
         }
     }
 }
Beispiel #8
0
        private void SnapRemove(ProgramBlock block)
        {
            VRTK_SnapDropZone currentVrtkZone = block.GetVRTKSnapDropZone();

            currentVrtkZone.ForceUnsnap();
        }