示例#1
0
    private void getPlayerInput()
    {
        if (godMode)
        {
            GameObject noteParent = GameObject.FindGameObjectWithTag("NoteParent");
            foreach (Transform child in noteParent.transform)
            {
                NoteMover note = child.GetComponent <NoteMover> ();
                if (note.isInZone() && note.isActive)
                {
                    note.gameObject.GetComponent <ParticleSystem> ().Play();
                    note.gameObject.GetComponent <SpriteRenderer> ().enabled = false;
                    correctInputs.Enqueue(new PlayerInput(note.inputName));
                    note.isActive = false;
                    Debug.Log(note.inputName);
                }
            }
        }
        else
        {
            string inputName = "";
            bool   success   = false;
            if (Input.GetButtonDown("jump"))
            {
                inputName = "jump";
                midiAnim.SetTrigger("Jump");
            }
            else if (Input.GetButtonDown("duck"))
            {
                inputName = "duck";
                midiAnim.SetTrigger("Duck");
            }
            else if (Input.GetButtonDown("longjump"))
            {
                inputName = "longjump";
                midiAnim.SetTrigger("LongJump");
            }
            else if (Input.GetButtonDown("highjump"))
            {
                inputName = "highjump";
                midiAnim.SetTrigger("HighJump");
            }

            if (inputName != string.Empty)
            {
                success = destroyCorrectNote(inputName);
                if (success)
                {
                    correctInputs.Enqueue(new PlayerInput(inputName));
                }
                else
                {
                    Invoke(inputName, inputDelay);
                }
            }
        }
    }
示例#2
0
    private bool destroyCorrectNote(string inputName)
    {
        bool       success    = false;
        GameObject noteParent = GameObject.FindGameObjectWithTag("NoteParent");

        foreach (Transform child in noteParent.transform)
        {
            NoteMover note = child.GetComponent <NoteMover> ();
            if (note.isInZone() && note.inputName == inputName && note.isActive)
            {
                note.gameObject.GetComponent <ParticleSystem> ().Play();
                note.gameObject.GetComponent <SpriteRenderer> ().enabled = false;
                note.isActive = false;
                success       = true;
            }
        }
        return(success);
    }