예제 #1
0
        public void OnTriggerEnter(Collider other)
        {
            if (isPressing || disabled || keyboard.disabled || !keyboard.initialized)
            {
                return;
            }

            Mallet mallet = other.gameObject.GetComponent <Mallet> ();

            if (mallet != null)
            {
                if (!mallet.isMovingDownward)
                {
                    return;
                }

                if (mallet.hand == Mallet.MalletHand.Left && keyboard.leftPressing)
                {
                    return;
                }
                else if (mallet.hand == Mallet.MalletHand.Right && keyboard.rightPressing)
                {
                    return;
                }

                if (_Press != null && _Press.MoveNext())
                {
                    StopCoroutine(_Press);
                }
                _Press = Press(other, mallet);
                StartCoroutine(_Press);
            }
        }
예제 #2
0
        private IEnumerator Press(Collider other, Mallet mallet)
        {
            isPressing = true;

            if (mallet.hand == Mallet.MalletHand.Left)
            {
                keyboard.leftPressing = true;
            }
            else if (mallet.hand == Mallet.MalletHand.Right)
            {
                keyboard.rightPressing = true;
            }

            mallet.HandleTriggerEnter(this);
            HandleTriggerEnter(other);

            transform.localPosition = pressedPosition;

            yield return(new WaitForSeconds(0.125f));

            transform.localPosition = defaultPosition;
            isPressing = false;

            if (mallet.hand == Mallet.MalletHand.Left)
            {
                keyboard.leftPressing = false;
            }
            else if (mallet.hand == Mallet.MalletHand.Right)
            {
                keyboard.rightPressing = false;
            }
        }
예제 #3
0
        public override void OnInteractionTrigger(InteractionModes mode)
        {
            Collider other  = gameObject.GetComponent <Collider>();
            Mallet   mallet = other.gameObject.GetComponent <Mallet>();

            _Press = Press(other, mallet);
            StartCoroutine(_Press);
        }
예제 #4
0
        private IEnumerator Press(Collider other, Mallet mallet)
        {
            isPressing            = true;
            keyboard.leftPressing = true;

            HandleTriggerEnter(other);

            transform.localPosition = pressedPosition;

            yield return(new WaitForSeconds(0.125f));

            transform.localPosition = defaultPosition;
            isPressing            = false;
            keyboard.leftPressing = false;

            OnFinish();
        }
예제 #5
0
 private void Start()
 {
     mallet = GetComponent <Mallet> ();
 }
예제 #6
0
 private void Start()
 {
     mallet = GetComponent <Mallet> ();
     //controllerCharacteristics = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Left | InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;
     controllerCharacteristics = (mallet.hand == Mallet.MalletHand.Left) ? InputDeviceCharacteristics.Left | InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.HeldInHand : InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller | InputDeviceCharacteristics.HeldInHand;
 }
        private void Start()
        {
            mallet = GetComponent <Mallet> ();

            role = (mallet.hand == Mallet.MalletHand.Left) ? InputDeviceRole.LeftHanded : InputDeviceRole.RightHanded;
        }