Beispiel #1
0
    private void OnExitBtnClicked()
    {
        note       = null;
        longNote   = null;
        circleNote = null;

        this.gameObject.SetActive(false);
    }
    private void SpawnNotes()
    {
        notesPool = new GameObject(this.gameObject.name + " NotesPool");

        // Next index for the array "singleNote".
        int indexOfNextNote = 0;

        // Next index for the array "singleNote".
        int indexOfNextLongNote = 0;

        // Check if there are still notes in the track, and check if the next note is within the bounds we intend to show on screen.
        while (indexOfNextNote < singleNote.Count)
        {
            // Instantiate a new music note. (Search "Object Pooling" for more information if you wish to minimize the delay when instantiating game objects.)
            // We don't care about the position and rotation because we will set them later in MusicNote.Initialize(...).
            RecorderNote musicNote = ((GameObject)Instantiate(RecordConductor.instance.musicNotePrefab, startPos.transform.position, startPos.transform.rotation)).GetComponent <RecorderNote>();

            musicNote.Initialize(RecordConductor.instance, this, startPos, endPos, singleNote[indexOfNextNote]);

            musicNote.transform.SetParent(notesPool.transform);

            // Update the next index.
            indexOfNextNote++;
        }

        while (indexOfNextLongNote < longNoteStart.Count)
        {
            // Instantiate a new music note. (Search "Object Pooling" for more information if you wish to minimize the delay when instantiating game objects.)
            // We don't care about the position and rotation because we will set them later in MusicNote.Initialize(...).


            RecorderLongNote longNote = Instantiate(RecordConductor.instance.musicLongNotePrefab, startPos.transform.position, startPos.transform.rotation).GetComponent <RecorderLongNote>();

            longNote.startNote.GetComponent <RecorderNote>().Initialize(RecordConductor.instance, this, startPos, endPos, longNoteStart[indexOfNextLongNote]);

            longNote.endNote.GetComponent <RecorderNote>().Initialize(RecordConductor.instance, this, startPos, endPos, longNoteEnd[indexOfNextLongNote]);

            longNote.Initialize(RecordConductor.instance, this, startPos, endPos);

            longNote.transform.SetParent(notesPool.transform);

            // Update the next index.
            indexOfNextLongNote++;
        }
    }
Beispiel #3
0
    public void Init(RecorderLongNote input)
    {
        longNote = input;

        isLongNoteToggle.gameObject.SetActive(true);

        isLongNoteToggle.isOn = true;

        beatTxt2.gameObject.SetActive(true);

        inputField2.gameObject.SetActive(true);

        beatTxt1.text = "Start Beat : ";

        inputField1.text = input.startNote.GetComponent <RecorderNote>().beat.ToString();

        beatTxt2.text = "End Beat : ";

        inputField2.text = input.endNote.GetComponent <RecorderNote>().beat.ToString();
    }
Beispiel #4
0
    private void OnConfirmBtnClicked()
    {
        if (isLongNoteToggle.isOn)
        {
            float startBeatToSave = float.Parse(inputField1.text);

            float endBeatToSave = float.Parse(inputField2.text);

            if (!CanAddBeat(startBeatToSave) || !CanAddBeat(endBeatToSave))
            {
                return;
            }


            if (note != null)
            {
                note.recorder.DeleteNote(note.beat);

                note.recorder.longNoteStart.Add(startBeatToSave);

                note.recorder.longNoteEnd.Add(endBeatToSave);

                note.recorder.UpdateNote();
            }
            else if (longNote != null)
            {
                longNote.recorder.DeleteLongNote(longNote.startNote.GetComponent <RecorderNote>().beat, longNote.endNote.GetComponent <RecorderNote>().beat);

                longNote.recorder.longNoteStart.Add(startBeatToSave);

                longNote.recorder.longNoteEnd.Add(endBeatToSave);

                longNote.recorder.UpdateNote();
            }
        }
        else
        {
            float beatToSave = float.Parse(inputField1.text);

            if (!CanAddBeat(beatToSave))
            {
                return;
            }

            if (note != null)
            {
                note.recorder.DeleteNote(note.beat);

                note.recorder.singleNote.Add(beatToSave);

                note.recorder.UpdateNote();
            }
            else if (longNote != null)
            {
                longNote.recorder.DeleteLongNote(longNote.startNote.GetComponent <RecorderNote>().beat, longNote.endNote.GetComponent <RecorderNote>().beat);

                longNote.recorder.singleNote.Add(beatToSave);

                longNote.recorder.UpdateNote();
            }
            else if (circleNote != null)
            {
                circleNote.recorder.DeleteNote(circleNote.beat);

                circleNote.recorder.singleNote.Add(beatToSave);

                circleNote.recorder.UpdateNote();
            }
        }



        note       = null;
        longNote   = null;
        circleNote = null;

        this.gameObject.SetActive(false);
    }