static void LoadNote(Chart chart, uint tick, int noteNumber, uint length, List <NoteFlag> flagsList
                         , Dictionary <int, int> chartFileNoteToRawNoteLookup
                         , Dictionary <int, Note.Flags> chartFileNoteToFlagLookup
                         , Dictionary <int, Note.Flags> rawNoteDefaultFlagsLookup
                         )
    {
        Debug.Assert(chartFileNoteToRawNoteLookup != null, "Must provide a note lookup dictionary");
        // Load chart file note to a raw note
        {
            int noteFret;
            if (chartFileNoteToRawNoteLookup.TryGetValue(noteNumber, out noteFret))
            {
                // Optional. Load any default flags that come with notes. Useful for automatically attaching cymbal flags for pro drums
                Note.Flags flags;
                if (rawNoteDefaultFlagsLookup == null || !rawNoteDefaultFlagsLookup.TryGetValue(noteFret, out flags))
                {
                    flags = Note.Flags.None;
                }

                Note newNote = new Note(tick, noteFret, length, flags);
                chart.Add(newNote, false);
            }
        }

        // Optional. Load any flags that are parsed on a seperate tick
        if (chartFileNoteToFlagLookup != null)
        {
            Note.Flags flags;
            if (chartFileNoteToFlagLookup.TryGetValue(noteNumber, out flags))
            {
                NoteFlag parsedFlag = new NoteFlag(tick, flags, noteNumber);
                flagsList.Add(parsedFlag);
            }
        }
    }
    static void LoadStandardNote(Chart chart, uint tick, int noteNumber, uint length, List <NoteFlag> flagsList)
    {
        Note.GuitarFret?noteFret = null;
        switch (noteNumber)
        {
        case (0):
            noteFret = Note.GuitarFret.Green;
            break;

        case (1):
            noteFret = Note.GuitarFret.Red;
            break;

        case (2):
            noteFret = Note.GuitarFret.Yellow;
            break;

        case (3):
            noteFret = Note.GuitarFret.Blue;
            break;

        case (4):
            noteFret = Note.GuitarFret.Orange;
            break;

        case (5):
            NoteFlag forcedFlag = new NoteFlag(tick, Note.Flags.Forced);
            flagsList.Add(forcedFlag);
            break;

        case (6):
            NoteFlag tapFlag = new NoteFlag(tick, Note.Flags.Tap);
            flagsList.Add(tapFlag);
            break;

        case (7):
            noteFret = Note.GuitarFret.Open;
            break;

        default:
            return;
        }

        if (noteFret != null)
        {
            Note newNote = new Note(tick, (int)noteFret, length);
            chart.Add(newNote, false);
        }
    }
Exemple #3
0
        bool Judge(NoteBase note, Transform tf, float judgePhase)
        {
            var touch     = TouchProvider.Instance;
            var info      = touch.PressCheck(note.Lane);
            var processed = false;

            switch (note.Type)
            {
            case NoteType.Kick:
                if (info == PressInfo.Tap)
                {
                    ScoreSubmit(Calculate(judgePhase));

                    processed = true;

                    // SFX
                    if (!noteFlag.HasFlag(NoteFlag.Kick))
                    {
                        NotesFX.Instance.Kick();
                    }

                    noteFlag |= NoteFlag.Kick;
                }

                break;

            case NoteType.Dribble:
                var d = (Dribble)note;

                if (d.IsFirstNote)
                {
                    if (info == PressInfo.Tap)
                    {
                        ScoreSubmit(Calculate(judgePhase));
                        NotesFX.Instance.DribbleStart();
                    }
                    processed = true;
                }

                if (info != PressInfo.None && judgePhase <= 0)
                {
                    ScoreSubmit(JudgeState.Great);
                    processed = true;
                    if (d.IsLastNote)
                    {
                        NotesFX.Instance.DribbleStop();
                    }
                    if (!noteFlag.HasFlag(NoteFlag.Dribble))
                    {
                        NotesFX.Instance.Dribble();
                    }

                    noteFlag |= NoteFlag.Dribble;
                }

                break;

            case NoteType.Knock:
                if (info == PressInfo.Slide)
                {
                    processed = true;
                    ScoreSubmit(JudgeState.Great);
                    if (!noteFlag.HasFlag(NoteFlag.Knock))
                    {
                        NotesFX.Instance.Knock();
                    }

                    noteFlag |= NoteFlag.Knock;
                }
                else if (info == PressInfo.Tap && judgePhase < -judgeThreshold * 0.5f)
                {
                    ScoreSubmit(JudgeState.Ok);
                    if (!noteFlag.HasFlag(NoteFlag.Knock))
                    {
                        NotesFX.Instance.Knock();
                    }

                    noteFlag |= NoteFlag.Knock;
                }

                break;

            case NoteType.Volley:
                var v = (Volley)note;

                if (info == PressInfo.Tap)
                {
                    processed = true;
                    ScoreSubmit(Calculate(judgePhase));
                    if (v.IsFirstNote && !noteFlag.HasFlag(NoteFlag.Receive))
                    {
                        NotesFX.Instance.Receive();
                        noteFlag |= NoteFlag.Receive;
                    }
                    else if (v.IsLastNote && !noteFlag.HasFlag(NoteFlag.Spike))
                    {
                        NotesFX.Instance.Spike();
                        noteFlag |= NoteFlag.Spike;
                    }
                    else if (!noteFlag.HasFlag(NoteFlag.Toss))
                    {
                        NotesFX.Instance.Toss();
                        noteFlag |= NoteFlag.Toss;
                    }
                }
                break;

            case NoteType.Puck:
                if (info != PressInfo.None && judgePhase <= 0)
                {
                    ScoreSubmit(JudgeState.Great);
                    processed = true;
                    if (!noteFlag.HasFlag(NoteFlag.Puck))
                    {
                        NotesFX.Instance.Puck();
                    }

                    noteFlag |= NoteFlag.Puck;
                }
                break;

            case NoteType.Rotate:
                //todo 回転
                break;

            case NoteType.Vibrate:
                //todo 振動
                break;
            }
            if (processed)
            {
                StartCoroutine(DelayedDestroy(note, notesDic[note].gameObject));
                notesDic.Remove(note);
            }
            return(processed);
        }
Exemple #4
0
        void ProcessNotes()
        {
            if (!aud.isPlaying)
            {
                return;
            }
            var audioTime = aud.time;

            noteFlag = NoteFlag.None;

            Beat beat = currentChart.Beat;
            var  time = GetTimeOfMeasure(beat, currentChart.Bpm);

            CurrentTime = CalculateCurrentTime(audioTime);

            if (metronomeTime.Count > 0 && metronomeTime.Peek() <= audioTime)
            {
                metronomeTime.Dequeue();
                NotesFX.Instance.Metronome();
            }

            if (Music.IsPlaying)
            {
                deltaTime = (ulong)(audioTime * mul) - prevTime;
            }

            foreach (var note in notesDic.ToList())
            {
                var noteTime = time + notesTimes[note.Key] - audioTime;

                if (noteTime < -judgeThreshold && note.Value != null)
                {
                    ScoreSubmit(JudgeState.Bad);
                    Destroy(note.Value.gameObject);
                    notesDic.Remove(note.Key);
                    continue;
                }

                if (note.Value == null)
                {
                    if (note.Key.Type == NoteType.Dribble && longNoteMeshCaches.ContainsKey(note.Key))
                    {
                        longNoteMeshCaches.Remove(note.Key);
                    }
                    continue;
                }
                var pos = note.Value.localPosition;
                note.Value.localPosition = new Vector3(pos.x, pos.y, Distance(hiSpeed, (time + speededNotesTimes[note.Key] - CurrentTime)));

                if (note.Key.Type == NoteType.Dribble)
                {
                    var l = longNoteMeshCaches.ContainsKey(note.Key) ? longNoteMeshCaches[note.Key]
                                                  : longNoteMeshCaches[note.Key] = note.Value.gameObject.GetComponentInChildren <LongNoteMeshModifier>();
                    var prev = (note.Key as Dribble).Previous;

                    if (l != null && notesDic.ContainsKey(prev) && notesDic[prev] != null)
                    {
                        var prevPos = notesDic[prev].position - note.Value.position;
                        prevPos.z     = -prevPos.z;
                        l.EndPosition = prevPos;
                    }
                }

                if (-judgeThreshold < noteTime &&
                    noteTime < judgeThreshold &&
                    !notesDic
                    .Where(k => k.Key.Lane == note.Key.Lane)
                    .Any(k => notesTimes[k.Key] < notesTimes[note.Key])
                    )
                {
                    Judge(note.Key, note.Value, noteTime);
                }
            }
            prevTime = (ulong)(audioTime * mul);
        }