Пример #1
0
    // Invoked when a gesture is complete.
    // Return true, if the gesture must be detected again, false otherwise
    public bool GestureComplete(uint userId, KinectWrapper.Gestures gesture,
		KinectWrapper.SkeletonJoint joint, Vector3 screenPos)
    {
        string sGestureText = gesture + " detected";
        //string ges=gesture.ToString();
        //bool gest;

        if(
            //(!state_right)&&
            gesture.ToString().Equals("SweepLeft")){
            state_right=true;
            print ("SweepRight detected");
            player.transform.Rotate(0,-90,0);
            status_player=quat_clock*status_player;

        }

        /*if(!gesture.Equals("SweepLeft")&&state_right){
            state_right=false;
            print ("state_right converted to false");
        }*/

        if(//(!state_left)&&
            gesture.ToString().Equals("SweepRight")){
            state_left=true;
                     state_right=true;
                        print ("SweepLeft detected");
                        player.transform.Rotate(0,90,0);
            status_player=quat_anti*status_player;
            /*
            print ("SweepLeft detected");
            player.transform.Rotate(0,90,0);*/
        }
        if(status_player*size_terrain==status&&state_right){
                //print ("enterd in condition 1");
                if(status.x!=0){
                    print ("enterd in condition 1");
                    if((player.transform.position.z-terrain_array[((index-4)%32+32)%32].transform.position.z)*(player.transform.position.z-terrain_array[((index-1)%32+32)%32].transform.position.z)<0){
                    print ("initial position="+player.transform.position.ToString());
                        player.transform.Translate(0,0,(terrain_array[((index-4)%32+32)%32].transform.position.z+terrain_array[((index-1)%32+32)%32].transform.position.z)/2-player.transform.position.z);
                print ("final position="+player.transform.position.ToString());
                }
                }
                else if(status.z!=0){
                    print ("enterd in condition 2");
                    if((player.transform.position.x-terrain_array[((index-4)%32+32)%32].transform.position.x)*(player.transform.position.x-terrain_array[((index-1)%32+32)%32].transform.position.x)<0){
                        print ("initial position="+player.transform.position.ToString());
                        player.transform.Translate((terrain_array[((index-4)%32+32)%32].transform.position.x+terrain_array[((index-1)%32+32)%32].transform.position.x)/2-player.transform.position.z,0,0);
                        print ("final position="+player.transform.position.ToString());
                    }
                }
        state_right=false;
        }
        /*if(!gesture.Equals("SweepRight")&&state_left){
            state_left=false;
            print ("state_left converted to false");
        }*/
        if(gesture == KinectWrapper.Gestures.Click)
            sGestureText += string.Format(" at ({0:F1}, {1:F1})", screenPos.x, screenPos.y);

        //GestureInfo.guiText.text = sGestureText;

        return true;
    }