Esempio n. 1
0
 private void HandAttachedUpdate(Hand hand)
 {
     if (isAutomaic)
     {
         if (SteamVR_Input.GetState("Shoot", hand.handType))
         {
             Shoot();
         }
         if (Input.GetKey(KeyCode.K))
         {
             Shoot();
         }
     }
     else
     {
         if (SteamVR_Input.GetStateDown("Shoot", hand.handType))
         {
             Shoot();
         }
         if (Input.GetKeyDown(KeyCode.K))
         {
             Shoot();
         }
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        touch = SteamVR_Input.GetState("Maze", "ray", steamVR_Behaviour_Boolean.inputSource);

        this.GetComponent <LineRenderer>().enabled = touch;

        if (touch)
        {
            Ray ray = new Ray(transform.position, transform.forward);
            //Debug.DrawLine(this.transform.position, this.transform.position + transform.forward * 2, Color.yellow);

            lineRenderer = GetComponent <LineRenderer>();
            lineRenderer.SetPosition(0, ray.origin);
            lineRenderer.SetPosition(1, ray.origin + ray.direction * linelen);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, linelen))
            {
                if (hit.collider.gameObject.tag == "magic")
                {
                    hit.collider.gameObject.SetActive(false);
                    Magic++;
                }

                /*else if(hit.collider.gameObject.tag == "obstacle")
                 * {
                 *  hit.collider.gameObject.SetActive(false);
                 * }*/
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log(SteamVR_Input.GetState("/actions/htc_viu/in/viu_press_00", SteamVR_Input_Sources.LeftHand));

        /* if (SteamVR_Input.GetState("/actions/htc_viu/in/viu_press_00")) {
         *   Debug.Log("Hello");
         * }*/
    }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     // If lefthand trigger held down
     if (SteamVR_Input.GetState("GrabPinch", leftHand))
     {
         // Calculate movement of 2D Object
         CalculateMovement();
     }
 }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (standard_low.transform.position.y < -10)
        {
            img.close      = 1;
            audioP.enabled = false;
        }

        isTrigger = SteamVR_Input.GetState("Maze", "hold", steamVR_Behaviour_Boolean.inputSource);

        //Move();

        //start = true;
        //prevD = Vector3.Distance(standard_low.transform.position, new Vector3(0, 0, 0));


        //Debug.Log(isTrigger);
        if (start)
        {
            Move();
            standard_low.transform.rotation = Q;
        }
        else
        {
            if (isTrigger)
            {
                //Debug.Log("innn");
                //All.transform.position = new Vector3(cam.transform.position.x + 2, cam.transform.position.y + 3f, cam.transform.position.z - 3);
                //All.transform.rotation = new Quaternion(0, cam.transform.rotation.y, 0, 0);
                standard_low.transform.position = new Vector3(cam.transform.position.x, cam.transform.position.y, cam.transform.position.z);
                //All.transform.position = standard_low.transform.position + bias;
                x = standard_low.transform.position.x - this.transform.position.x;
                //x = 0;
                y = standard_low.transform.position.y - this.transform.position.y;
                //y = 1;
                z = standard_low.transform.position.z - this.transform.position.z;
                //z = 0;
                //this.transform.position = new Vector3(standard_low.transform.position.x, standard_low.transform.position.y, standard_low.transform.position.z);
                //All.transform.position = new Vector3(cam.transform.position.x + 2, cam.transform.position.y + 4f, cam.transform.position.z - 6);
                start = true;
                prevD = Vector3.Distance(standard_low.transform.position, new Vector3(0, 0, 0));
            }
        }

        if (move)
        {
            move0.transform.position        += (move0.transform.forward * 1.25f + move0.transform.up) * Time.deltaTime * 2;
            standard_low.transform.position += (move0.transform.forward * 1.3f + move0.transform.up) * Time.deltaTime * 2;
        }
        if (move0.transform.position.y >= move1.transform.position.y)
        {
            //move0.transform.position = move1.transform.position;
            //standard_low.transform.position = move0.transform.position + new Vector3(0, 0.5f, 0);
            move = false;
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (grab.GetStateUp(pose.inputSource))
        {
            Drop();
            holding = false;
            driving = false;
        }

        if (!SteamVR_Input.GetState("Point", SteamVR_Input_Sources.RightHand) && !SteamVR_Input.GetState("GrabPinch", SteamVR_Input_Sources.RightHand))
        {
            GameObject coll = updatePointer();

            pointerSphere.SetActive(coll != null);

            if (coll != null && SteamVR_Input.GetState("Select", SteamVR_Input_Sources.RightHand))
            {
                player.transform.rotation = Quaternion.LookRotation(-1 * coll.transform.right, ship.transform.forward);
            }
        }
        else
        {
            pointerSphere.SetActive(false);
        }


        /*
         *
         * JoyStick control... perhaps checkout upgrading to circular drive with to axes..
         *
         */
        if (driving)
        {
            if (grab.GetState(pose.inputSource))
            {
                Vector3 difference = joystick.transform.position - transform.position;

                if (Vector3.Magnitude(difference) < 1)
                {
                    Quaternion rot = Quaternion.LookRotation(-1 * difference, Vector3.Cross(Vector3.right, difference));
                    joystick.transform.rotation = rot;
                }
                else
                {
                    driving = false;
                    joystick.transform.localRotation = Quaternion.Euler(0, 0, 0);
                }
            }
            else
            {
                driving = false;
                joystick.transform.localRotation = Quaternion.Euler(0, 0, 0);
            }
        }
    }
Esempio n. 7
0
 bool IsInputActive()
 {
     if (VRIsActive)
     {
         return(SteamVR_Input.GetState("TrackpadActive", SteamVR_Input_Sources.LeftHand));
     }
     else
     {
         return(Input.GetMouseButton(1));
     }
 }
Esempio n. 8
0
 private void OnTriggerStay(Collider other)
 {
     if (other.name == "StartButton")
     {
         start = SteamVR_Input.GetState("LookLetter", "PressStart", behaviour_Boolean.inputSource);
         if (start)
         {
             startButton.onClick.Invoke();
         }
     }
 }
Esempio n. 9
0
 private void OnTriggerStay(Collider other)
 {
     if (SteamVR_Input.GetState("HoldHandle", "Hold", bb.inputSource) && !isPut)
     {
         transform.SetParent(phonograph.transform);
         transform.localPosition = locationOnPlatform;
         transform.localRotation = Quaternion.Euler(rotationOnPlatform);
         particle.SetActive(false);
         isPut = true;
     }
 }
Esempio n. 10
0
 private void OnTriggerStay(Collider other)
 {
     if (SteamVR_Input.GetState("HoldHandle", "Hold", bb.inputSource) && other.name == "HandleHead" && ControlCD.isPut)
     {
         handleOrigin.transform.localRotation = Quaternion.Euler(originRotation.x, originRotation.y, ComputeAngle());
         isHold = true;
     }
     if (!SteamVR_Input.GetState("HoldHandle", "Hold", bb.inputSource))
     {
         isHold = false;
     }
 }
    //Prende collider para poder agarrar joyas, abrir puertas, etc.
    void Grabbing()
    {
        isTriggered = SteamVR_Input.GetState("isGrabbinRight", hand.handType);

        if (isTriggered)
        {
            grabCollider.SetActive(true);
        }
        else
        {
            grabCollider.SetActive(false);
        }
    }
Esempio n. 12
0
 private void OnTriggerStay(Collider other)
 {
     if (other.name == "Letter")
     {
         take = SteamVR_Input.GetState("LookLetter", "Take", behaviour_Boolean.inputSource);
         if (take)
         {
             gameAction.GetComponent <StartToSavePrincess>().MyPrincessDontWorry();
             taking = true;
         }
         else if (taking)
         {
             taking = false;
         }
     }
 }
Esempio n. 13
0
    //Controller actions
    #region
    void ToolControllerAction()
    {
        toolTrackPos  = SteamVR_Input.GetVector2(trackPadPos_tool, SteamVR_Input_Sources.Any, true);
        toolTrackDown = SteamVR_Input.GetStateDown(trackPadClick_tool, SteamVR_Input_Sources.Any, true);
        toolTrack     = SteamVR_Input.GetState(trackPadClick_tool, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_tool, SteamVR_Input_Sources.Any, true))
        {
            toolSet.TriggerDown();
        }
        else if (toolTrackDown && toolTrackPos.y < 0.5f && toolTrackPos.y > -0.5f)
        {
            if (toolTrackPos.x < -0.5f)
            {
                toolSet.PadRight(Button.release);
                toolSet.PadLeft(Button.press);
                toolPressed = true;
            }
            else if (toolTrackPos.x > 0.5f)
            {
                toolSet.PadLeft(Button.release);
                toolSet.PadRight(Button.press);
                toolPressed = true;
            }
        }
        else if (toolTrackDown && toolTrackPos.x < 0.5f && toolTrackPos.x > -0.5f)
        {
            if (toolTrackPos.y < -0.5f)
            {
                toolSet.PadDown();
            }
            else if (toolTrackPos.y > 0.5f)
            {
                toolSet.PadUp();
            }
        }

        if (!toolTrack && toolPressed)
        {
            toolSet.PadLeft(Button.release);
            toolSet.PadRight(Button.release);
            toolPressed = false;
        }
    }
Esempio n. 14
0
        private void Update()
        {
            if (!_interactableObject.IsGrabbing)
            {
                return;
            }

            bool state = SteamVR_Input.GetState("GrabPinch", SteamVR_Input_Sources.RightHand, true);

            if (state)
            {
                if (_currFirePause <= 0)
                {
                    FireBullet();
                    _currFirePause = FIRE_PAUSE;
                }

                _currFirePause -= Time.deltaTime;
            }
            else
            {
                _currFirePause = 0;
            }

            WeaponBody.transform.localRotation = Quaternion.Lerp(WeaponBody.transform.localRotation, _defaultRotation, _recoilRecoverSpeed * Time.deltaTime);

            return;

            //For single shooting
            bool stateDown = SteamVR_Input.GetStateDown("GrabPinch", SteamVR_Input_Sources.RightHand);

            if (stateDown)
            {
                FireBullet();
            }
            //TODO Добавить помимо поворота при отдаче и смещение оружия
            WeaponBody.transform.localRotation = Quaternion.Lerp(WeaponBody.transform.localRotation, _defaultRotation, _recoilRecoverSpeed * Time.deltaTime);


            if (interactable.isHovering != lastHovering) //save on the .tostrings a bit
            {
                lastHovering = interactable.isHovering;
            }
        }
Esempio n. 15
0
    void SteeringControllerAction()
    {
        steeringTrackPos  = SteamVR_Input.GetVector2(trackPadPos_steering, SteamVR_Input_Sources.Any, true);
        steeringTrackDown = SteamVR_Input.GetStateDown(trackPadClick_steering, SteamVR_Input_Sources.Any, true);
        steeringTrack     = SteamVR_Input.GetState(trackPadClick_steering, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_steering, SteamVR_Input_Sources.Any, true))
        {
            behaviourTool.Engage();
            steeringTriggerDown = true;
        }
        else if (steeringTrackDown && steeringTrackPos.y < 0.5f && steeringTrackPos.y > -0.5f)
        {
            if (steeringTrackPos.x < -0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Left);
            }
            else if (steeringTrackPos.x > 0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Right);
            }
        }
        else if (steeringTrack && steeringTrackPos.x < 0.5f && steeringTrackPos.x > -0.5f)
        {
            if (steeringTrackPos.y < -0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Down);
            }
            else if (steeringTrackPos.y > 0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Up);
            }
        }


        if (!SteamVR_Input.GetState(triggerClick_steering, SteamVR_Input_Sources.Any, true) && steeringTriggerDown)
        {
            behaviourTool.DisEngage();
            steeringTriggerDown = false;
        }
    }
Esempio n. 16
0
    void Update()
    {
        rTriggerState = SteamVR_Input.GetState("InteractUI", SteamVR_Input_Sources.RightHand);
        lTriggerState = SteamVR_Input.GetState("InteractUI", SteamVR_Input_Sources.LeftHand);

        if (lTriggerState && selectedHand == "right")
        {
            selectedHand = "left";
            pStateController.SelectHand("left");
        }
        else if (rTriggerState && selectedHand == "left")
        {
            selectedHand = "right";
            pStateController.SelectHand("right");
        }

        selectedTriggerState = (selectedHand == "right") ? rTriggerState : lTriggerState;
        if (selectedTriggerState == true)
        {
            if (EventSystem.current.currentSelectedGameObject != null)
            {
                ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, new BaseEventData(EventSystem.current), ExecuteEvents.submitHandler);
            }
        }

        x_ButtonState = SteamVR_Input.GetState("ResetHeight", SteamVR_Input_Sources.LeftHand);
        if (x_ButtonState == true)
        {
            player.transform.localScale = Vector3.one * (playerHeight / player.eyeHeight);
        }

        if (itemAttached && itemAttached.CompareTag("popcan"))
        {
            popcanBehaviour pb = itemAttached.GetComponent <popcanBehaviour>();

            if (hand.currentAttachedObject == null)
            {
                pb.inHand = false;
                pb.ResetMaterial();
            }
            else
            {
                pb.inHand = true;
            }
        }

        if (itemAttached && itemAttached.CompareTag("bomb"))
        {
            bombBehaviour bb = itemAttached.GetComponent <bombBehaviour>();

            if (hand.currentAttachedObject == null)
            {
                bb.inHand = false;
            }
            else
            {
                bb.hand           = hand;
                bb.inHand         = true;
                bb.triggerPressed = rTriggerState;
            }
        }
        //itemAttached = hand.currentAttachedObject;

        if (itemAttached && itemAttached.CompareTag("spray"))
        {
            sprayCan sc = itemAttached.GetComponent <sprayCan>();

            sc.inHand = false;

            if (gameObject.GetComponent <Hand>().currentAttachedObject != null)
            {
                sc.inHand = true;
            }

            sc.TriggerState(rTriggerState);
        }

        if (itemAttached && itemAttached.CompareTag("fence"))
        {
            fenceTool fence = itemAttached.GetComponent <fenceTool>();

            if (gameObject.GetComponent <Hand>().currentAttachedObject == null)
            {
                fence.inHand = false;
            }
            else
            {
                fence.inHand = true;
            }
        }
        itemAttached = gameObject.GetComponent <Hand>().currentAttachedObject;

        pauseButtonState = SteamVR_Input.GetState("Pause", SteamVR_Input_Sources.LeftHand);
        if (pauseButtonState == true)
        {
            if (GameManager.gm.paused)
            {
                GameManager.gm.paused = false;
                GameManager.gm.UnPaused();
            }
            else
            {
                GameManager.gm.paused = true;
                GameManager.gm.Paused();
            }
        }
    }
Esempio n. 17
0
    void Update()
    {
        Debug.Log("Training Index: " + trainingIndex);
        switch (trainingIndex)
        {
        case 0:
            bool leftTurn  = SteamVR_Input.GetState("SnapTurnLeft", SteamVR_Input_Sources.LeftHand) || SteamVR_Input.GetState("SnapTurnLeft", SteamVR_Input_Sources.RightHand);
            bool rightTurn = SteamVR_Input.GetState("SnapTurnRight", SteamVR_Input_Sources.LeftHand) || SteamVR_Input.GetState("SnapTurnRight", SteamVR_Input_Sources.RightHand);
            if (leftTurn && !completedLeft)
            {
                message = "Turn your head Right by pressing right on the thumb sticks";
                UpdateText(message);
                completedLeft = true;
            }
            else if (rightTurn && !completedRight)
            {
                message = "Turn your head Left by pressing left on the thumb sticks";
                UpdateText(message);
                completedRight = true;
            }
            else if (completedLeft && completedRight)
            {
                message = "Great job, now let's try movement";
                UpdateText(message);
                trainingIndex++;
            }
            else if (!completedLeft && !completedRight)
            {
                message = "Turn your head using the thumb sticks";
                UpdateText(message);
            }
            break;

        case 1:
            if (waitTime <= 0)
            {
                if (!gameEnabled)
                {
                    teleportArea.SetActive(true);
                    SetActiveRecursively(teleportArea, true);
                    teleporting.SetActive(true);
                    gameEnabled = true;
                }
                bool teleported = SteamVR_Input.GetState("Teleport", SteamVR_Input_Sources.LeftHand) || SteamVR_Input.GetState("Teleport", SteamVR_Input_Sources.RightHand);
                if (triedTeleporting && !teleported && originalPosition != this.gameObject.transform.position)
                {
                    teleportCount++;
                    triedTeleporting = false;
                    waitTime         = 0.5f;
                }
                if (teleported)
                {
                    triedTeleporting = true;
                    originalPosition = this.gameObject.transform.position;
                }

                if (teleportCount == 0)
                {
                    message = "Try Teleporting around the room by pressing the thumbstick forward";
                    UpdateText(message);
                }
                else if (teleportCount >= 0 && teleportCount < 3)
                {
                    message = "Try Teleporting " + (3 - teleportCount).ToString() + " times to get used to teleporting around the room";
                    UpdateText(message);
                }
                else if (teleportCount == 3)
                {
                    message = "Great job, now let's try sorting recycling. Press the green button on the pedastal to begin once you are ready";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime    = baseWaitTime;
                    gameEnabled = false;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 2:
            if (waitTime <= 0)
            {
                if (!gameEnabled)
                {
                    SetActiveRecursively(startPedestal, true);
                    blueBin.SetActive(true);
                    gameEnabled = true;
                }
                if (gm.waveIndex == 1)
                {
                    message = "Great job, now let's try sorting contaminants.";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime    = baseWaitTime;
                    gameEnabled = false;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 3:
            if (waitTime <= 0)
            {
                if (!gameEnabled)
                {
                    redBin.SetActive(true);
                    gameEnabled = true;
                }
                if (gm.waveIndex == 2)
                {
                    message = "Great, ready for a special item?";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime    = baseWaitTime;
                    gameEnabled = false;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 4:
            if (waitTime <= 0)
            {
                if (!gameEnabled)
                {
                    redBin.SetActive(true);
                    gameEnabled = true;
                }
                if (gm.waveIndex == 3)
                {
                    message = "Great job, now let's try tools";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime    = baseWaitTime;
                    gameEnabled = false;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 5:
            if (waitTime <= 0)
            {
                if (!gameEnabled)
                {
                    SetActiveRecursively(shop, true);
                    gameEnabled = true;
                }
                if (gm.waveIndex == 4)
                {
                    message = "Great job, now let's try a bomb";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime    = baseWaitTime;
                    gameEnabled = false;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 6:
            if (waitTime <= 0)
            {
                if (gm.waveIndex == 5)
                {
                    message = "Great job, now let's try disenfecting items";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime = baseWaitTime;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 7:
            if (waitTime <= 0)
            {
                if (gm.waveIndex == 6)
                {
                    message = "Great job, the Tutorial is complete!";
                    UpdateText(message);
                    trainingIndex++;
                    waitTime = baseWaitTime;
                }
            }
            else
            {
                waitTime -= Time.deltaTime;
            }
            break;

        case 8:
            SceneManager.LoadScene("MainMenu");
            break;

        default:
            break;
        }
    }