Ejemplo n.º 1
0
    public void Update(float time, GuitarSustainHitKnowledge sustainKnowledge, uint noteStreak)
    {
        var currentSustains = sustainKnowledge.currentSustains;

        int inputMask            = GuitarInput.GetFretInputMask();
        int extendedSustainsMask = sustainKnowledge.extendedSustainsMask;

        int shiftCount;
        int shiftedExtendedSustainsMask = GameplayInputFunctions.BitshiftToIgnoreLowerUnusedFrets(extendedSustainsMask, out shiftCount);

        foreach (GuitarSustainHitKnowledge.SustainKnowledge sustain in currentSustains.ToArray())     // Take a copy so we can remove as we go
        {
            if (noteStreak == 0)
            {
                BreakSustain(time, sustain);
            }
            else if (extendedSustainsMask != 0)
            {
                int shiftedInputMask = inputMask >> shiftCount;

                if ((shiftedInputMask & ~shiftedExtendedSustainsMask) != 0)
                {
                    BreakSustain(time, sustain);
                }
            }
            else if (!GameplayInputFunctions.ValidateFrets(sustain.note, inputMask, noteStreak))
            {
                BreakSustain(time, sustain);
            }
        }
    }
Ejemplo n.º 2
0
    void UpdateNoteKnowledge(float time, HitWindow <GuitarNoteHitKnowledge> hitWindow, int inputMask, bool strummed, uint noteStreak, GuitarNoteHitKnowledge nextNoteToHit, GuitarSustainHitKnowledge sustainKnowledge)
    {
        // Check if it's valid to query the last hit note
        if (noteStreak <= 0 || lastNoteHit == null || !hitWindow.IsWithinTimeWindow(lastNoteHit.note, nextNoteToHit != null ? nextNoteToHit.note : null, time))
        {
            lastNoteHit = null;
        }

        if (nextNoteToHit != null && noteStreak > 0)    // None of this knowledge should be used for recovery
        {
            if (nextNoteToHit.strumCounter > 1)
            {
                nextNoteToHit.strumCounter = 1;     // Make this still valid to hit because it's still in the hit window for a reason
            }
            // Fill out note knowledge
            if (GameplayInputFunctions.ValidateFrets(nextNoteToHit.note, inputMask, noteStreak, sustainKnowledge.extendedSustainsMask))
            {
                nextNoteToHit.fretValidationTime = time;
            }
            else
            {
                nextNoteToHit.lastestFretInvalidationTime = time;
            }

            if (GameplayInputFunctions.ValidateStrum(nextNoteToHit.note, canTap, strummed, noteStreak))
            {
                nextNoteToHit.strumValidationTime = time;
            }
            else
            {
                nextNoteToHit.lastestStrumInvalidationTime = time;
            }

            if (strummed)
            {
                if (lastNoteHit != null && lastNoteHit.strumCounter <= 0)// lastNoteHit.note.type != Note.Note_Type.Strum)
                {
                    ++lastNoteHit.strumCounter;
                }
                else
                {
                    ++nextNoteToHit.strumCounter;
                }
            }
        }
    }
Ejemplo n.º 3
0
    void RecoveryDetect(float time, HitWindow <GuitarNoteHitKnowledge> hitWindow, int fretInputMask, bool strummed, uint noteStreak)
    {
        var noteKnowledgeList = hitWindow.noteKnowledgeQueue;

        // Search to see if user is hitting a note ahead
        List <GuitarNoteHitKnowledge> validatedNotes = new List <GuitarNoteHitKnowledge>();

        foreach (GuitarNoteHitKnowledge noteKnowledge in noteKnowledgeList)
        {
            // Collect all notes the user is possibly hitting
            if (
                GameplayInputFunctions.ValidateFrets(noteKnowledge.note, fretInputMask, noteStreak) &&
                GameplayInputFunctions.ValidateStrum(noteKnowledge.note, canTap, strummed, noteStreak)
                )
            {
                validatedNotes.Add(noteKnowledge);
            }
        }

        if (validatedNotes.Count > 0)
        {
            // Recovery algorithm
            // Select the note closest to the strikeline
            float aimYPos = ChartEditor.Instance.visibleStrikeline.transform.position.y + 0.25f;  // Added offset from the note controller

            GuitarNoteHitKnowledge selectedNote = validatedNotes[0];

            float dis = -1;

            foreach (GuitarNoteHitKnowledge validatedNote in validatedNotes)
            {
                if (!selectedNote.note.controller)
                {
                    return;
                }

                NoteController noteController = selectedNote.note.controller;

                float distance = Mathf.Abs(aimYPos - noteController.transform.position.y);
                if (distance < dis || dis < 0)
                {
                    selectedNote = validatedNote;
                    dis          = distance;
                }
            }

            int index = noteKnowledgeList.IndexOf(selectedNote);
            GuitarNoteHitKnowledge note = noteKnowledgeList[index];

            // Recovery missed notes
            if (index > 0)
            {
                Debug.Log("Missed notes when performing recovery. Notes skipped = " + index);
            }

            for (int missedCounter = 0; missedCounter < index; ++missedCounter)
            {
                MissNote(time, MissSubType.NoteMiss, noteKnowledgeList[missedCounter]);
            }

            HitNote(time, note);

            // We fill out our own knowledge
            note.fretValidationTime  = time;
            note.strumValidationTime = time;
            if (strummed)
            {
                ++note.strumCounter;
            }
        }
        else if (strummed)
        {
            MissNote(time, MissSubType.Overstrum);
            Debug.Log("Missed due to strumming when there were no notes to strum during recovery");
        }
    }