コード例 #1
0
        private void GazeInputSourcePreview_GazeMoved(GazeInputSourcePreview sender, GazeMovedPreviewEventArgs args)
        {
            _gazePosition.SetPosition(args.CurrentPoint.EyeGazePosition);

            if (_gazeHidPositionsParser == null)
            {
                _gazeHidPositionsParser = new GazeHidPositionsParser(args.CurrentPoint.SourceDevice);
            }
            var positions = _gazeHidPositionsParser.GetGazeHidPositions(args.CurrentPoint.HidInputReport);

            _leftEyePosition.SetPosition(positions.LeftEyePosition);
            _rightEyePosition.SetPosition(positions.RightEyePosition);
            _headPosition.SetPosition(positions.HeadPosition);
            _headRotatePosition.SetPosition(positions.HeadRotation);

            if (_leftEyePosition.Z == 0 && _rightEyePosition.Z == 0)
            {
                Blink?.Invoke(BlinkType.Both);
            }
            else
            {
                if (_leftEyePosition.Z == 0)
                {
                    Blink?.Invoke(BlinkType.Left);
                }
                if (_rightEyePosition.Z == 0)
                {
                    Blink?.Invoke(BlinkType.Right);
                }
            }

            GazeMoved?.Invoke();
        }
コード例 #2
0
    private void HandleInput(Vector2 aimDirection)
    {
        if (Input.GetKeyDown(KeyCode.E) && ropeAttached != true)
        {
            if (activateHook == false)
            {
                crosshairSprite.sprite       = crosshairForHook;
                activateOrNotGun.activateGun = false;
                activateHook            = true;
                blinkData.numberOfBlink = 6;
                blinkData.Invoke("ToggleState" + blinkData.isBlinking, blinkData.startDelay);
                Activable.sprite = Grapplin;
            }
            else
            {
                crosshairSprite.sprite       = crosshairForGun;
                activateOrNotGun.activateGun = true;
                activateHook            = false;
                blinkData.numberOfBlink = 6;
                blinkData.Invoke("ToggleState" + blinkData.isBlinking, blinkData.startDelay);
                Activable.sprite = Shot;
            }
        }

        if (Input.GetMouseButton(0) && activateHook != false)
        {
            if (ropeAttached)
            {
                return;
            }
            ropeRenderer.enabled = true;

            var hit = Physics2D.Raycast(playerPosition, aimDirection, ropeMaxCastDistance, ropeLayerMask);


            if (hit.collider != null)
            {
                ropeAttached = true;
                if (!ropePositions.Contains(hit.point))
                {
                    grapplinSoundEffect.Play();

                    transform.GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, 2f), ForceMode2D.Impulse);
                    ropePositions.Add(hit.point);
                    ropeJoint.distance            = Vector2.Distance(playerPosition, hit.point);
                    ropeJoint.enabled             = true;
                    ropeHingeAnchorSprite.enabled = true;
                    var emission = ropeHingeAnchorParticle.emission;
                    emission.enabled = true;
                }
            }

            else
            {
                ropeRenderer.enabled = false;
                ropeAttached         = false;
                ropeJoint.enabled    = false;
            }
        }

        if (Input.GetMouseButton(1))
        {
            ResetRope();
        }
    }