コード例 #1
0
 void OnApplicationQuit()
 {
     // uninitialize Kinect interaction
     if (interactionInited)
     {
         interactionInited = false;
         instance          = null;
     }
 }
コード例 #2
0
    //----------------------------------- end of public functions --------------------------------------//

    void Start()
    {
        instance          = this;
        interactionInited = true;

        for (int i = 0; i < 2; i++)
        {
            leftHandEvent.Add(HandEventType.None);
            lastLeftHandEvent.Add(HandEventType.None);
            rightHandEvent.Add(HandEventType.None);
            lastRightHandEvent.Add(HandEventType.None);
            leftHandState.Add(KinectInterop.HandState.Unknown);
            rightHandState.Add(KinectInterop.HandState.Unknown);
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        justHandGestureManager            = JustHandGestureManager.Instance;
        rightArmOrigin.transform.rotation = rightArm.transform.rotation;
        //	userID= manager.alUserIds[PLAYERNUM-1];
        //RIGHTARM
        if (holdPinchMode)
        {
            if (GetComponent <RobotController4>().leftArmOn)
            {
                if (leftArmIsChargable)
                {
                    // Get the userID right now so that we always have the most current userID in case we have a Kinect disconnect

                    if (justHandGestureManager.GetLastLeftHandEvent(PLAYERNUM) == JustHandGestureManager.HandEventType.Grip)
                    {
                        chargeCounterL++;
                        GameObject chargeParticle = leftArm.transform.Find("charge").gameObject;
                        chargeParticle.gameObject.SetActive(true);
                        chargeParticle.gameObject.particleSystem.startSize = .1f + chargeCounterL / 500;


                        Vector3 shakeAmt = new Vector3(Mathf.Sin(chargeCounterL) * shakeCamScale, 0f, 0f);
                        //playerCam.transform.localPosition += shakeAmt;

                        //leftArmOrigin.GetComponent<LineRenderer> ().enabled = true;
                    }
                    else if (justHandGestureManager.GetLastLeftHandEvent(PLAYERNUM) == JustHandGestureManager.HandEventType.Release)
                    {
                        GameObject chargeParticle = leftArm.transform.Find("charge").gameObject;
                        chargeParticle.gameObject.SetActive(false);

                        if (chargeCounterL >= leftArmChargeDurationFrames)
                        {
                            Instantiate(leftArmBullet, leftArmOrigin.transform.position, leftArmOrigin.transform.rotation);
                            GameObject shotParticle = leftArm.transform.Find("ShotOrigin/shotParticle").gameObject;
                            shotParticle.particleSystem.Emit(50);
                        }
                        chargeCounterL = 0f;
                    }
                }
                else
                {
                    if (justHandGestureManager.GetLastLeftHandEvent(PLAYERNUM) == JustHandGestureManager.HandEventType.Grip)
                    {
                        ShootLeftHandShot();
                        canShootL = false;
                    }
                    else
                    {
                        if (!leftArmIsChargable)
                        {
                            canShootL = true;
                        }
                    }
                }
            }

            if (GetComponent <RobotController4>().rightArmOn)
            {
                if (rightArmIsChargable)
                {
                    if (justHandGestureManager.GetLastRightHandEvent(PLAYERNUM) == JustHandGestureManager.HandEventType.Grip)
                    {
                        //Debug.Log("gripped");
                        chargeCounterR++;
                        GameObject chargeParticle = rightArm.transform.Find("charge").gameObject;
                        chargeParticle.gameObject.SetActive(true);
                        chargeParticle.gameObject.particleSystem.startSize = .1f + chargeCounterR / 500;

                        Vector3 shakeAmt = new Vector3(Mathf.Sin(chargeCounterR) * shakeCamScale, 0f, 0f);
                        //playerCam.transform.localPosition+=shakeAmt;

                        //line.
                    }
                    else if (justHandGestureManager.GetLastRightHandEvent(PLAYERNUM) == JustHandGestureManager.HandEventType.Release)
                    {
                        //Debug.Log("releaseed");


                        GameObject chargeParticle = rightArm.transform.Find("charge").gameObject;
                        chargeParticle.gameObject.SetActive(false);

                        if (chargeCounterR >= rightArmChargeDurationFrames)
                        {
                            Instantiate(rightArmBullet, rightArmOrigin.transform.position, rightArmOrigin.transform.rotation);
                            GameObject shotParticle = rightArm.transform.Find("ShotOrigin/shotParticle").gameObject;
                            shotParticle.particleSystem.Emit(50);
                        }
                        chargeCounterR = 0f;
                    }
                }
                else
                {
                    if (justHandGestureManager.GetLastRightHandEvent(PLAYERNUM - 1) == JustHandGestureManager.HandEventType.Grip)
                    {
                        ShootRightHandShot();
                        canShootR = false;
                    }
                    else
                    {
                        if (!rightArmIsChargable)
                        {
                            canShootR = true;
                        }
                    }
                }
            }
        }

        /*
         *
         *      else{
         * if (rapidPinchMode) {
         *
         *                              if (manager.GetLastLeftHandEvent () == InteractionManager.HandEventType.Grip) {
         *                                              ShootLeftHandShot ();
         *                                              canShootL = false;
         *                              } else {
         *                              if(!leftArmIsChargable){
         *                                              canShootL = true;
         *                              }
         *                              }
         *
         *
         *              }
         *
         *      /*
         *
         *      else {
         *
         *
         *                              if (manager.GetLastLeftHandEvent () == InteractionManager.HandEventType.Grip) {
         *                                              leftHandGripped = true;
         *                                              if (!leftHandShooting) {
         *                                                              StartCoroutine (ShootTheShotL ());
         *                                              }
         *
         *                              } else {
         *                                              leftHandGripped = false;
         *                              }
         *
         *                              if (manager.GetLastRightHandEvent () == InteractionManager.HandEventType.Grip) {
         *                                              rightHandGripped = true;
         *                                              if (!rightHandShooting) {
         *                                                              StartCoroutine (ShootTheShotR ());
         *                                              }
         *                              } else {
         *                                              rightHandGripped = false;
         *                              }
         *              }
         */
    }