Exemple #1
0
    public NoteBehaviour CreateNote(MIDIChart.Note noteData)
    {
        NoteBehaviour note;

        if (recycleList.Count == 0)
        {
            note = Instantiate(assetNote, transform);
        }
        else
        {
            note = recycleList.Dequeue();
        }
        note.Factory  = this;
        note.NoteData = noteData;
        note.gameObject.SetActive(true);
        return(note);
    }
    void Update()
    {
        var note = judger.NextJudgedNote;

        if (note != null && note != lastPlayedNote && note.beginBeat < BeatTime.beat)
        {
            //Debug.Log("Autoplay note " + note.beginBeat + " beginning at " + note.audioEndBeat);
            sequencer.PlaySynchronized(laser.trackIndex, note.audioEndBeat);
            lastPlayedNote = note;
        }

        if (isHolding && (startHoldTime + holdTolerance - Time.time) < 0)
        {
            model.transform.localScale += (new Vector3(0, modelInitialScale.y, 0) - model.transform.localScale) * Time.deltaTime * 3;
        }
        else
        {
            model.transform.localScale += (modelInitialScale - model.transform.localScale) * Time.deltaTime * 3;
        }
    }
Exemple #3
0
    void Start()
    {
        graph.Initialize();
        graph.gameObject.SetActive(false);

        foreach (UnityEngine.UI.Text text in textObjects)
        {
            text.color = new Color(text.color.r, text.color.g, text.color.b, 0);
            text.gameObject.SetActive(false);
        }

        foreach (CanvasRenderer canvasRenderer in canvasObjects)
        {
            canvasRenderer.SetAlpha(0);

            canvasRenderer.gameObject.SetActive(false);
        }

        List <MIDIChart.Track> validTracks = new List <MIDIChart.Track>();

        foreach (LaserBehaviour laser in laserHarp.GetComponentsInChildren <LaserBehaviour>())
        {
            if (!validTracks.Contains(laser.chart.tracks[laser.trackIndex]))
            {
                validTracks.Add(laser.chart.tracks[laser.trackIndex]);
            }
        }

        foreach (MIDIChart.Track track in validTracks)
        {
            MIDIChart.Note lastNote = track.notes[track.notes.Count - 1];

            if (endTime < lastNote.endBeat)
            {
                endTime = lastNote.endBeat;
            }
        }

        // Wait a little bit more before showing the results
        endTime += 1f;
    }
Exemple #4
0
 void Update()
 {
     MIDIChart.Note noteData = behaviour.NoteData;
     if (!shapeUpdated)
     {
         transform.localRotation = Quaternion.LookRotation(offsetPerBeat);
         transform.localScale    = new Vector3(1, 1, (noteData.endBeat - noteData.beginBeat) * offsetPerBeat.magnitude);
         shapeUpdated            = true;
     }
     if (noteData.endBeat < BeatTime.beat)
     {
         shapeUpdated = false;
         behaviour.Recycle();
     }
     else if (noteData.beginBeat < BeatTime.beat)
     {
         transform.localPosition = judgePosition;
         transform.localScale    = new Vector3(1, 1, (noteData.endBeat - BeatTime.beat) * offsetPerBeat.magnitude);
     }
     else
     {
         transform.localPosition = judgePosition + (noteData.beginBeat - BeatTime.beat) * offsetPerBeat;
     }
 }
    public MIDIChart.Note GetNoteOnBeat(float beat, float tolerance)
    {
        var tmpNote = new MIDIChart.Note {
            noteNum = -1, beginBeat = beat - tolerance
        };
        int index = Array.BinarySearch(notes, tmpNote, Comparer <MIDIChart.Note> .Create((note1, note2) => note1.beginBeat.CompareTo(note2.beginBeat)));

        if (index < 0)
        {
            index = ~index;
        }
        while (index + 1 < notes.Length && Mathf.Abs(notes[index + 1].beginBeat - beat) <= Mathf.Abs(notes[index].beginBeat - beat))
        {
            ++index;
        }
        Debug.Log(trackNumber + " " +
                  (index < notes.Length ? (beat - notes[index].beginBeat).ToString() + " " +
                   (Mathf.Abs(notes[index].beginBeat - beat) <= tolerance ? "Hit" : "Missed") : "Null Missed"));
        if (index < notes.Length && Mathf.Abs(notes[index].beginBeat - beat) <= tolerance)
        {
            return(notes[index]);
        }
        return(null);
    }