예제 #1
0
    // On button press, hit current note
    public void HitNote()
    {
        float delay     = elapsedBeat;
        float beatValue = notes[lastNoteIndex].beatValue * song.timeSignature.multiplier;

        // If we already played current note, try next one
        if (notes[lastNoteIndex].played && beatValue - elapsedBeat < NEXT_NOTE_THRESHOLD && lastNoteIndex + 1 < notes.Count)
        {
            delay       = elapsedBeat - beatValue;
            currentNote = notes[lastNoteIndex + 1];
        }
        else
        {
            currentNote = notes[lastNoteIndex];
        }

        if (currentNote.played)
        {
            currentNote = null;
            return;
        }

        // Compute score and play animation
        Score score = Score.ComputeScore(delay, true, currentNote.isRest);

        totalScore += score.value;
        currentNote.AnimateHit(score);

        if (currentNote.duration == 0 || score == Score.Miss)
        {
            currentNote = null;
        }
    }