public bool CheckIfActivated()
    {
        InputHelpers.IsPressed(controller.inputDevice, drawButton, out bool isGripped, activationThreshold);
        string heldSpell = (handName == "right") ? player.rightHandSpell : player.leftHandSpell;

        return(isGripped && (heldSpell == null || heldSpell == ""));
    }
Exemple #2
0
 void Update()
 {
     InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(controller), btn, out bool isPressed);
     if (isPressed)
     {
         PhotonNetwork.Disconnect();
         PhotonNetwork.LoadLevel(0);
     }
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(inputSource), inputButton, out bool isPressed, inputThreshold);

        //Start the movement
        if (!isMoving && isPressed)
        {
            StartMovement();
        }
        //Ending the movement
        else if (isMoving && !isPressed)
        {
            EndMovement();
        }
        //Updating the movement
        else if (isMoving && isPressed)
        {
            UpdateMovement();
        }
    }
    // Update is called once per frame
    void Update()
    {
        //est-ce que le jouer pese sur le bouton choisi? (Y)
        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(inputSource), inputButton, out bool isPressed, inputTreshold);

        //le mouvement commence
        if (!inMotion && isPressed)
        {
            startMove();
        }
        //le joueur a fini le mouvement
        else if (inMotion && !isPressed)
        {
            endMove();
        }
        //rafraichit le mouvement
        else if (inMotion && isPressed)
        {
            updateMove();
        }
    }
    private void Jump(Vector3 forceVector)
    {
        foreach (InputDevice inputDevice in inputDevices)
        {
            if (inputDevice.isValid)
            {
                InputHelpers.IsPressed(inputDevice, InputHelpers.Button.PrimaryButton, out isPressed);
                if (grounded && isPressed)
                {
                    Debug.Log("JUMP");
                    myBody.isKinematic = false;
                    foreach (LocomotionProvider locomotionProvider in locomotionProviders)
                    {
                        locomotionProvider.enabled = false;
                    }

                    myBody.AddForce(forceVector, ForceMode.Impulse);
                    grounded = false;
                }

                //if vertical velocity is 0 we're grounded and we can jump again
                if (myBody.IsSleeping())
                {
                    grounded           = true;
                    myBody.isKinematic = true;
                    foreach (LocomotionProvider locomotionProvider in locomotionProviders)
                    {
                        locomotionProvider.enabled = true;
                    }
                }

                //check if below the map, reset position
                if (transform.position.y < -5.0f)
                {
                    transform.position = originalPosition;
                    grounded           = true;
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // Get player controller position in worldspace
        Vector3 playerPos = playerGO.transform.TransformPoint(playerController.center + new Vector3(0f, playerController.height / 2f, 0));

        if (!CheckIfActivated())
        {
            transform.LookAt((hand.transform.position + (playerPos)) / 2f);
            // transform.LookAt(playerPos);
            transform.position = hand.transform.position + (planeOffsetForward * hand.transform.forward);
            if (visible && !forceVisible)
            {
                boxCollider.enabled  = false;
                meshRenderer.enabled = false;
                visible = false;
                if (edgeParticles)
                {
                    edgeParticles.Stop();
                }
                if (spellDisplayPanel != null)
                {
                    spellDisplayPanel.SetActive(false);
                }
            }
        }
        else
        {
            if (!visible && !interactor.isSelectActive)
            {
                boxCollider.enabled  = true;
                meshRenderer.enabled = true;
                visible = true;
                if (edgeParticles)
                {
                    edgeParticles.Play();
                }
            }
        }

        InputHelpers.IsPressed(controller.inputDevice, showSpellsButton, out bool showSpells, activationThreshold);
        string heldSpell = (handName == "right") ? player.rightHandSpell : player.leftHandSpell;

        if ((showSpells || Input.GetKey("v") && (heldSpell == null || heldSpell == "")))
        {
            if (spellDisplayPanel != null)
            {
                spellDisplayPanel.SetActive(true);
            }
        }
        else
        {
            if (spellDisplayPanel != null)
            {
                spellDisplayPanel.SetActive(false);
            }
        }

        if (Input.GetKeyDown("4"))
        {
            planeOffsetForward  += 0.5f;
            forceVisible         = true;
            boxCollider.enabled  = true;
            meshRenderer.enabled = true;
            visible = true;
            if (edgeParticles)
            {
                edgeParticles.Play();
            }
        }
        else if (Input.GetKeyDown("5"))
        {
            planeOffsetForward -= 0.1f;
        }
    }
Exemple #7
0
 //fonction qui teste si le bouton primaire est activé sur la manette donnée
 // param {XRController} : une manette
 public bool CheckIfPrimaryActive(XRController controller)
 {
     //est-ce que le bouton primaire A est pesé?
     InputHelpers.IsPressed(controller.inputDevice, primaryButton, out bool isActivated, activationThreshold);
     return(isActivated);
 }
Exemple #8
0
 public bool CheckIfActivated(XRController rechts)
 {
     InputHelpers.IsPressed(rechts.inputDevice, ActivationButton, out bool isPressed);
     return(isPressed);
 }
Exemple #9
0
 public bool CheckIfTriggered(XRController controller)
 {
     InputHelpers.IsPressed(controller.inputDevice, trigger, out bool isTriggered, activationThreshold);
     return(isTriggered);
 }
Exemple #10
0
 //Verifie si le bouton Trigger de la manette est activé
 public bool CheckIfActivated(XRController controller)
 {
     //si le bouton trigger est appuyé sur la manette, retourne True
     InputHelpers.IsPressed(controller.inputDevice, triggerButton, out bool isActivated, activationThreshold);
     return(isActivated);
 }
    // Update is called once per frame
    void Update()
    {
        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(inputSource), button, out bool isPressed, inputThreshold);
        //Start Movement
        if (!isMoving && isPressed)
        {
            StartMovement();
        }
        //End Movement
        else if (isMoving && !isPressed)
        {
            EndMovement();
        }
        //Update Movement
        else if (isMoving && isPressed)
        {
            UpdateMovement();
        }

        void StartMovement()
        {
            isMoving = true;
            positionList.Clear();
            var position = movementSource.position;

            positionList.Add(position);
            if (debugCubePrefab)
            {
                Destroy(Instantiate(debugCubePrefab, position, Quaternion.identity), 2);
            }
        }

        void EndMovement()
        {
            isMoving = false;
            //Create the gesture from the pos list
            Point[] pointArray = new Point[positionList.Count];
            for (int i = 0; i < positionList.Count; i++)
            {
                Vector2 screenPoint = Camera.main.WorldToScreenPoint(positionList[i]);
                pointArray[i] = new Point(screenPoint.x, screenPoint.y, 0);
            }
            Gesture newGesture = new Gesture(pointArray);

            if (creationMode)
            {
                newGesture.Name = newGestureName;
                trainingSet.Add(newGesture);

                string fileName = Application.persistentDataPath + "/" + newGestureName + ".xml";
                GestureIO.WriteGesture(pointArray, newGestureName, fileName);
            }
            else
            {
                Result result = PointCloudRecognizer.Classify(newGesture, trainingSet.ToArray());
                Debug.Log(result.GestureClass + ": " + result.Score);
                if (result.Score > recognitionThreshold)
                {
                    onRecognize?.Invoke(result.GestureClass);
                }
            }
        }

        void UpdateMovement()
        {
            Vector3 lastPosition = positionList[positionList.Count - 1];

            if (Vector3.Distance(movementSource.position, lastPosition) > newPositionThresholdDistance)
            {
                positionList.Add(movementSource.position);
                if (debugCubePrefab)
                {
                    Destroy(Instantiate(debugCubePrefab, movementSource.position, Quaternion.identity), 2);
                }
            }
        }
    }
Exemple #12
0
 private bool CheckIfActivated(XRController controller)
 {
     InputHelpers.IsPressed(controller.inputDevice, TeleportActivationButton, out bool isActivated, ActivationThreshold);
     return(isActivated && EnableTeleport);
 }
Exemple #13
0
 public bool CheckIfActivated(XRController controller) // public bool to see if the button on the controller has been pressed
 {
     InputHelpers.IsPressed(controller.inputDevice, teleportActivationButton, out bool isActivated, activationThreshold);
     return(isActivated); // return the output true to is activated
 }
 public bool CheckIfActivatedLeft(XRController controller)
 {
     //est-ce que le bouton Trigger est pesé?
     InputHelpers.IsPressed(controller.inputDevice, triggerButton, out bool isActivated, activationThreshold);
     return(isActivated);
 }
 //fonction qui retourne true/false
 public bool CheckIfActivatedRight(XRController controller)
 {
     //est-ce que le bouton secondaire (B) est pesé?
     InputHelpers.IsPressed(controller.inputDevice, secondaryButton, out bool isActivated, activationThreshold);
     return(isActivated);
 }
Exemple #16
0
 //---------------------------------------------------------------------------------
 // Function description
 //---------------------------------------------------------------------------------
 public bool CheckIfActivated(XRController controller)
 {
     InputHelpers.IsPressed(controller.inputDevice, teleportActivationButton, out bool isActivated);
     return(isActivated);
 }
 public bool CheckIfActivated(XRController controller)
 {
     InputHelpers.IsPressed(controller.inputDevice, selectionActivationButton, out bool isActivated, activationThreshold);
     return(isActivated);
 }
Exemple #18
0
 public bool CheckIfActivated(XRController controller)
 {
     InputHelpers.IsPressed(controller.inputDevice, grip, out bool isGripped, activationThreshold);
     return(isGripped);
 }