internal NodeObject MakeNode(string label, Vector3 position, Color color)
        {
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            sphere.transform.position   = position;
            sphere.transform.localScale = Vector3.one * (float)System.Math.Max(0.1, nodeScale) * this.modelScale;
            MeshRenderer renderer = sphere.GetComponent <MeshRenderer>();

            renderer.material.color = color;
            Rigidbody body = sphere.AddComponent <Rigidbody>();

            body.mass        = 0.05F;
            body.angularDrag = 0.05f;
            body.useGravity  = false; // turn off gravity
            body.drag        = 0.8f;
            SphereCollider collider = sphere.GetComponent <SphereCollider>();

            collider.material.bounciness = 1.0F;
            sphere.AddComponent <NVRCollisionSoundObject>();
            NVRInteractableItem interactable = sphere.AddComponent <NVRInteractableItem>();

            interactable.CanAttach = true;
            interactable.DisableKinematicOnAttach = true;
            interactable.EnableKinematicOnDetach  = false;
            interactable.EnableGravityOnDetach    = false;
            NodeObject node = sphere.AddComponent <NodeObject>();

            node.label = label;
            return(node);
        }
 void checkUnlockAll()
 {
     if (unlocked1 && unlocked2 && unlocked3)
     {
         NVRInteractableItem driveScript = GetComponent <NVRInteractableItem>();
         driveScript.CanAttach = true;
     }
 }
示例#3
0
    public void NVRInitialize()
    {
        _nvrinitialized = true;

        _item = GetComponent <NVRInteractableItem>();
        _item.VelocityMagic        = positionLerpSpeed;
        _item.AngularVelocityMagic = angularLerpSpeed;
    }
示例#4
0
 public void Start()
 {
     interactable = GetComponentInParent <NewtonVR.NVRInteractableItem>();
     if (flairStickyLayer == 0)
     {
         flairStickyLayer = LayerMask.NameToLayer("flairSticky");
     }
 }
示例#5
0
    // Use this for initialization
    void Start()
    {
        player   = GameObject.FindGameObjectWithTag("Player");
        interact = this.GetComponent <NVRInteractableItem>();

        this.taken = false;
        this.GetComponent <Rigidbody>().useGravity = false;
        this.initialPos = this.transform.position;
        this.initialRot = this.transform.rotation;
    }
示例#6
0
    // Use this for initialization
    void Start()
    {
        // Set up newtonVR -
        NVRInteractableItem nvrItem = this.GetComponent <NVRInteractableItem>();

        nvrItem.CanAttach = true;
        nvrItem.DisableKinematicOnAttach = true;
        nvrItem.EnableKinematicOnDetach  = true;
        nvrItem.EnableGravityOnDetach    = false;
        //nvrItem.DisablePhysicalMaterialsOnAttach = true;
    }
示例#7
0
    private void Grab(NVRInteractable obj)
    {
        if (obj is NVRInteractableItem)
        {
            NVRInteractableItem item = obj as NVRInteractableItem;
            item.OnBeginInteraction.Invoke();
        }

        obj.transform.SetParent(GrabTransform);
        obj.transform.localPosition = Vector3.zero;
        obj.Rigidbody.velocity      = Vector3.zero;

        grabbed = obj.transform;
    }
示例#8
0
    public void TurnIntoPlayerMadeObject(GameObject go, Color color, float liveTime)
    {
        if (liveTime > 0)
        {
            FadeAndDestroy fad = go.AddComponent <FadeAndDestroy>();
            fad.delayTime = liveTime;
//			fad.explosion = playerObjectExplosion;
        }

        NVRInteractableItem interactableItem = go.GetComponent <NVRInteractableItem>();

        if (!interactableItem)
        {
            interactableItem = go.GetComponentInChildren <NVRInteractableItem>();
        }
        if (!interactableItem)
        {
            go.AddComponent <NVRInteractableItem>();
        }

        MeshRenderer renderer = go.GetComponent <MeshRenderer>();

        if (!renderer)
        {
            renderer = go.GetComponentInChildren <MeshRenderer>();
        }
        if (renderer)
        {
            renderer.material.color = color;
        }

        Rigidbody rb = go.GetComponent <Rigidbody> ();

        if (!rb)
        {
            Rigidbody r = go.GetComponentInChildren <Rigidbody> ();
            if (r.gameObject.GetComponent <NVRInteractable> ())
            {
                r.isKinematic = true;
            }
        }
        else
        {
            rb.isKinematic = true;
        }

        go.transform.position = getPlayerSpawnObjectPosition();
        go.tag = "PlayerCreated";
    }
示例#9
0
    /*
     * snapToBolt -
     * Tool colliding with bolt snaps to bolts position with offset.
     * NVR Hand and NVR interactable item functionality is disbaled so only RatchetRotation affects tool.
     * Set bolt's parent to the tool
     * Swich Colliders to sphere collider
     * */
    public void ToolSnapToBolt(Collider col)
    {
        if (CheckToolAndBoltStateForSnap(col))
        {
            if (col.gameObject.GetComponent <Bolt_NVR>().partSize == this.gameObject.GetComponent <Tool>().toolSize)
            {
                col.gameObject.GetComponent <Bolt_NVR>().snappedTool = this.gameObject;
                toolInRotationMode = true;
                snappedObject      = col.gameObject;

                if (OnToolSnappedToBoltEvent != null)
                {
                    Debug.Log("we are oion ");
                    //OnToolSnappedToBoltEvent(this, snappedObject);
                }

                NVRInteractableItem interactableItem = this.gameObject.GetComponent <NVRInteractableItem>();
                interactingControllerRM = interactableItem.AttachedHand.gameObject;

                // turn off the NVRHand on this controller
                // turn off the hand on this controller
                NVRHand hand = interactableItem.AttachedHand.GetComponent <NVRHand>();
                hand.EndInteraction(interactableItem);
                hand.enabled = false;
                interactableItem.EndInteraction(hand);
                interactableItem.enabled = false;

                interactingControllerRM.gameObject.GetComponent <RotationHand_NVR>().currentRotationTool = this.gameObject;

                //Switch Colliders
                this.gameObject.GetComponent <SphereCollider>().enabled  = true;
                this.gameObject.GetComponent <CapsuleCollider>().enabled = false;

                //Set the position of the tool to the bolt
                this.gameObject.transform.position
                    = col.transform.position + col.gameObject.GetComponent <Bolt_NVR>().offsetToolAttach;

                Quaternion Q = new Quaternion();
                Q.eulerAngles = new Vector3(0f, this.transform.rotation.eulerAngles.y, 0f) + snapRotationOffset;
                this.gameObject.transform.rotation = Q;

                this.GetComponent <Rigidbody>().velocity        = Vector3.zero;
                this.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;

                Debug.Log("Finsihsed snapping");
            }
        }
    }
示例#10
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "key_black" || col.gameObject.name == "key_grey" || col.gameObject.name == "key_gold" || col.gameObject.name == "key")
        {
            col.gameObject.GetComponent <Rigidbody>().isKinematic = true;

            col.gameObject.transform.rotation = Quaternion.Euler(0f, -180f, 90f);
            originalParent = col.gameObject.transform.parent;
            col.gameObject.transform.parent        = this.transform;
            col.gameObject.transform.localPosition = new Vector3(-0.0178f, -0.0872f, 0.005059996f);

            if (col.gameObject.name == "key_black")
            {
                col.gameObject.GetComponent <BoxCollider>().enabled = false;
                NVRInteractableItem driveScript = GetComponent <NVRInteractableItem>();
                driveScript.CanAttach = true;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (controller.GetPressDown(triggerButton))
        //IPL.Set_Left_Interacting(true); IPL.Set_Player_Interacting(true);
        {
            IPL.SetRightTriggerInteracting(true);
            if (anthology)
            {
                if (anthology.active)
                {
                    anthology.activate(true);
                }
            }
        }
        if (controller.GetPressUp(triggerButton))
        //IPL.Set_Left_Interacting(false); IPL.Set_Player_Interacting(false);
        {
            IPL.SetRightTriggerInteracting(false);
            if (objectHovering)
            {
                objectHovering.GetComponent <Rigidbody>().isKinematic     = false;
                objectHovering.GetComponent <Rigidbody>().velocity        = controller.velocity + new Vector3(controller.velocity.x * -2, 0, controller.velocity.z * -2);
                objectHovering.GetComponent <Rigidbody>().angularVelocity = controller.angularVelocity;
            }
            Invoke("ClearDelayedHold", .25f);

            if (anthology)
            {
                if (anthology.active)
                {
                    anthology.activate(true);
                }
            }
        }
        if (controller.GetPressDown(gripButton))
        //IPL.Set_Left_Interacting(true); IPL.Set_Player_Interacting(true);
        {
            IPL.SetRightGripped(true);
            if (aimer)
            {
                aimer.SetActive(true);
                if (IPL.rightHand.CurrentlyInteracting)
                {
                    delayedHold = IPL.rightHand.CurrentlyInteracting.GetComponent <NVRInteractableItem>();
                }
                else if (objectHovering && IPL.rightTriggerInteractive)
                {
                    delayedHold = objectHovering;
                }
            }
        }
        if (controller.GetPressUp(gripButton))
        //IPL.Set_Left_Interacting(false); IPL.Set_Player_Interacting(false);
        {
            if (aimer)
            {
                aimer.SetActive(false);
            }

            IPL.SetRightGripped(false);

            /*
             * if (IPL.rightHand.CurrentlyInteracting)
             * {
             *
             *  NVRInteractable test = IPL.rightHand.CurrentlyInteracting;
             *  StartCoroutine(delayForReactivate(test));
             *  test.GetComponent<NVRInteractableItem>().enabled = false;
             *  IPL.rightHand.EndInteraction(test);
             *  test.GetComponent<Rigidbody>().AddForce(raycastOrigin.transform.forward * 500);
             *  StartCoroutine("vibrateRight", .1f);
             *  PlaySound(source, sounds[1], true);
             * }
             * else if (objectHovering && IPL.rightTriggerInteractive)
             * {
             *  NVRInteractableItem test = objectHovering;
             *  objectHovering = null;
             *  test.GetComponent<Rigidbody>().isKinematic = false;
             *  test.GetComponent<Rigidbody>().AddForce(raycastOrigin.transform.forward * 500);
             *  StartCoroutine("vibrateRight", .1f);
             *  PlaySound(source, sounds[1], true);
             * }
             */
            if (delayedHold)
            {
                if (IPL.rightHand.CurrentlyInteracting)
                {
                    IPL.rightHand.EndInteraction(delayedHold);
                }
                else if (objectHovering && IPL.rightTriggerInteractive)
                {
                    objectHovering = null;
                }
                delayedHold.GetComponent <NVRInteractableItem>().enabled = false;
                delayedHold.GetComponent <Rigidbody>().isKinematic       = false;
                delayedHold.GetComponent <Rigidbody>().AddForce(raycastOrigin.transform.forward * 500);
                StartCoroutine("vibrateRight", .1f);
                PlaySound(source, sounds[1], true);
            }
        }

        if (controller.GetPressDown(aButton) || controller.GetPressDown(bButton) || controller.GetPressDown(joystickPress))
        {
            IPL.SetRightButtonInteracting(true);
            anthology.activate(true);
        }
        if (controller.GetPressUp(aButton) || controller.GetPressUp(bButton) || controller.GetPressUp(joystickPress))
        {
            IPL.SetRightButtonInteracting(false);
            anthology.activate(false);
        }


        if (!IPL.GetRightTriggerInteracting())
        {
            hovering       = Physics.OverlapBox(raycastOrigin.transform.position + raycastOrigin.transform.forward * IPL.range, IPL.halfExtents, raycastOrigin.transform.rotation);
            objectHovering = IPL.CheckForObject(hovering, raycastOrigin.transform, true);

            //indicator.transform.position = hovering.transform.position;
            if (objectHovering)
            {
                ringDisplay.transform.position = objectHovering.transform.position;
                ringDisplay.transform.LookAt(Camera.main.transform);
            }
            playedWhoosh = false;
        }
        else
        {
            if (objectHovering) //&& !IPL.rightHand.CurrentlyInteracting)
            {
                if (!playedWhoosh)
                {
                    StartCoroutine("vibrateRight", .1f);
                    PlaySound(source, sounds[0], true);
                    playedWhoosh = true;
                }
                objectHovering.GetComponent <Rigidbody>().isKinematic = true;
                objectHovering.transform.position = Vector3.MoveTowards(objectHovering.transform.position, raycastOrigin.transform.position, IPL.pullSpeed * Time.deltaTime);
            }
        }
        if (objectHovering && IPL.GetRightTriggerInteracting())
        {
            if (objectHovering.GetComponent <PotionStack>())
            {
                pullPotion = true;
            }
            else
            {
                pullPotion = false;
            }
            pullSomething = true;
        }
        else
        {
            pullSomething = false;
        }
        if (objectHovering && !IPL.GetRightTriggerInteracting())
        {
            ringDisplay.enabled = true;
        }
        else
        {
            ringDisplay.enabled = false;
        }
    }
 void ClearDelayedHold()
 {
     delayedHold = null;
 }
示例#13
0
文件: HintPlayer.cs 项目: iszen/LABOR
 private void Awake()
 {
     item = GetComponent <PickableItem>();
 }
示例#14
0
 void Awake()
 {
     item = GetComponent <NVRInteractableItem>();
 }
示例#15
0
 public void Start()
 {
     sqrOverlapRadius = overlapRadius * overlapRadius;
     interactable     = GetComponentInParent <NewtonVR.NVRInteractableItem>();
 }
示例#16
0
 void Awake()
 {
     interactableItem = GetComponent <PickableItem>();
 }
示例#17
0
 void Start()
 {
     keyPosition           = this.gameObject.transform.position;
     interactableScriptKey = mysteryKey.GetComponent <NVRInteractableItem> ();
 }