예제 #1
0
 public void init(ArrayList liste, Note.Which piste, MainManager m)
 {
     this.newParticle = null;
     this.beginning = 0;
     this.initialized = false;
     this.noteStart = 0;
     this.noteObjects = new ArrayList();
     this.isActive = false;
     this.nextNoteTime = 0;
     this.previousNoteEnd = 0;
     this.soundPlayed = false;
     this.mainManager = m;
     this.piste = piste;
     this.notesListe = liste;
     this.beginning = Time.timeSinceLevelLoad;
     this.initialized = true;
     StartCoroutine(playNotes());
     StartCoroutine(renderNotes());
     this.toucheObject.renderer.enabled = true;
 }
    // Update is called once per frame
    void Update()
    {
        noteGauche = noteDroite = noteGenous = Note.Which.NONE;

        if(Input.GetKey(KeyCode.LeftArrow))
            noteGauche = Note.Which.A;
        if(Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.UpArrow))
        {
            if(noteGauche == Note.Which.NONE)
                noteGauche = Note.Which.B;
            else
                noteDroite = Note.Which.B;
        }
        if(Input.GetKey(KeyCode.RightArrow))
        {
            if(noteGauche == Note.Which.NONE)
                noteGauche = Note.Which.C;
            else
                noteDroite = Note.Which.C;
        }
        if(Input.GetKey(KeyCode.Q))
        {
            if(noteGauche == Note.Which.NONE)
                noteGauche = Note.Which.E;
            else
                noteDroite = Note.Which.E;
        }
        if(Input.GetKey(KeyCode.D))
        {
            if(noteGauche == Note.Which.NONE)
                noteGauche = Note.Which.F;
            else
                noteDroite = Note.Which.F;
        }
        if(Input.GetKey(KeyCode.Space))
        {
            noteGenous = Note.Which.D;
        }

        bonusActivated = false;
        if(Input.GetKey(KeyCode.LeftAlt))
        {
            bonusActivated = true;
        }

        //update all of the bones positions
        if (ks.kinectPlugged && sw.pollSkeleton ())
        {
            //Head management index=3
            headPos = new Vector3 (
                        sw.bonePos [0, 3].x,
                        sw.bonePos [0, 3].y,
                        sw.bonePos [0, 3].z);

            //check if player is still tracked
            if(headPos.Equals(lastHeadPos))
                return;
            lastHeadPos = headPos;

            //LeftHand management index=7
            leftHand = new Vector3 (
                        sw.bonePos [0, 7].x,
                        sw.bonePos [0, 7].y,
                        sw.bonePos [0, 7].z);

            //RightHand management index=11
            rightHand = new Vector3 (
                        sw.bonePos [0, 11].x,
                        sw.bonePos [0, 11].y,
                        sw.bonePos [0, 11].z);

            //LeftKnee management index=15
            leftKnee = new Vector3 (
                        sw.bonePos [0, 13].x,
                        sw.bonePos [0, 13].y,
                        sw.bonePos [0, 13].z);

            //RightKnee management index=19
            rightKnee = new Vector3 (
                        sw.bonePos [0, 17].x,
                        sw.bonePos [0, 17].y,
                        sw.bonePos [0, 17].z);

            //détermination des notes
            if(!headPos.Equals(new Vector3(0,0,0)))
            {
                noteGauche = getNote (leftHand);
                noteDroite = getNote (rightHand);
                noteGenous = getNoteGenous();
            }

            bonusActivated = checkBonus();
        }
    }
    // Use this for initialization
    void Start()
    {
        sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        if(sw == null)
        {
            Instantiate(KinectPrefab);
            sw = (SkeletonWrapper) FindObjectOfType(typeof(SkeletonWrapper));
        }

        ks = (KinectSensor) FindObjectOfType(typeof(KinectSensor));

        this.mainManager = (MainManager) FindObjectOfType(typeof(MainManager));
        noteGauche = noteDroite = noteGenous = Note.Which.NONE;
        bonusActivated = false;
    }