Пример #1
0
    void FetchCurrentNote()
    {
        while (index < hitEventsList.Count)
        {
            //gets latest timing points
            offsetTime = (AudioSettings.dspTime - startTime) * 1000 + scrollDelay;

            //Debug.Log("OFFSET TIME: " + offsetTime);
            if (timingIndex < timingPointsList.Count && offsetTime >= timingPointsList[timingIndex].getOffset())
            {
                scrollDelay = delayHandler.GetComponent <DelayHandler>().UpdateBPM(timingPointsList[timingIndex].getMsPerBeat());
                if (timingPointsList[timingIndex].getPlaymode() == 0) // step
                {
                    baseScore          = noteBaseScore;
                    memoryMode         = false;
                    invertedMemoryMode = false;
                }
                else
                {
                    baseScore          = memoryBaseScore;
                    memoryMode         = timingPointsList[timingIndex].getPlaymode() == 1 ? true : false;
                    invertedMemoryMode = timingPointsList[timingIndex].getPlaymode() == -1 ? true : false;
                }
                timingIndex++;
            }

            noteOffsetTime  = (AudioSettings.dspTime - startTime) * 1000;
            noteOffsetTime += scrollDelay;
            HitEvent hitObject = hitEventsList[index];

            if (noteOffsetTime >= hitObject.getOffset())
            {
                //Debug.Log("Note " + hitObject.getOffset() + " Spawn time: " + offsetTime + "\nNote offset: " + noteOffsetTime);
                if ((hitObject.IsNote() || hitObject.IsHold()) && !noteFlag)
                {
                    spawnNotes(hitObject);
                }
                noteFlag = true;
                if (hitObject.isFlashYellow() || hitObject.isFlashGreen() || hitObject.isFlashRed() || hitObject.isFlashBlue())
                {
                    HitEvent memoryNote = new HitEvent();
                    memoryNote.setSequenceStart(isSequenceStart);
                    if (hitObject.isFlashYellow())
                    {
                        StartCoroutine(FlashMemoryPrompt("yellow", hitObject.IsflashBlack()));
                        memoryNote.setKey("0");
                        memorySequence.Enqueue(memoryNote);
                    }
                    if (hitObject.isFlashGreen())
                    {
                        StartCoroutine(FlashMemoryPrompt("green", hitObject.IsflashBlack()));
                        memoryNote.setKey("1");
                        memorySequence.Enqueue(memoryNote);
                    }
                    if (hitObject.isFlashRed())
                    {
                        StartCoroutine(FlashMemoryPrompt("red", hitObject.IsflashBlack()));
                        memoryNote.setKey("2");
                        memorySequence.Enqueue(memoryNote);
                    }
                    if (hitObject.isFlashBlue())
                    {
                        StartCoroutine(FlashMemoryPrompt("blue", hitObject.IsflashBlack()));
                        memoryNote.setKey("3");
                        memorySequence.Enqueue(memoryNote);
                    }
                    isSequenceStart = false;
                }
                else
                {
                    isSequenceStart = true;
                }


                if (index + 1 < hitEventsList.Count)
                {
                    HitEvent nextHitObject = hitEventsList[index + 1];
                    int      nextHitMode   = FetchNotePlayMode(nextHitObject);
                    // Check if the next note is a memory input corresponding to the start of memory sequence
                    if (memorySequence.Count > 0)
                    {
                        if (nextHitMode != 0 && nextHitObject.IsNote() && memorySequence.Peek().isSequenceStart())
                        {
                            StopCoroutine(HandleMemoryStart(nextHitObject, nextHitMode));
                            StartCoroutine(HandleMemoryStart(nextHitObject, nextHitMode));
                        }
                    }
                    StopCoroutine(HandleMemorySprites(hitObject, FetchNotePlayMode(hitObject)));
                    StartCoroutine(HandleMemorySprites(hitObject, FetchNotePlayMode(hitObject)));
                }
            }
            else // if next hit object doesn't need to be spawned now
            {
                break;
            }

            noteFlag = false;
            index++;
        }
    }