/// <summary>
    /// ノーツの判定処理
    /// </summary>
    /// <param name="currentFlame"></param>
    /// <param name="judgeLane"></param>
    /// <param name="judgeData"></param>
    public JudgeType Judge(ref NotesType type, int currentFlame, int judgeLane, int deltaFlame, JudgeData judgeData)
    {
        JudgeType judgeResult = JudgeType.None;

        if (nextNotes[judgeLane] == null)
        {
            if (ButtonDownInput(judgeLane))
            {
                SetLaneBeamColor(judgeLane, beamColor.noneColor);
            }
            return(judgeResult);
        }

        int differenceFlame    = nextNotes[judgeLane].TimingFlame - currentFlame;
        int endDifferenceFlame = 0;

        type = nextNotes[judgeLane].Type;

        switch (type)
        {
        case NotesType.Normal:

            judgeResult = NormalNoteJudge(differenceFlame, judgeLane, judgeData);
            break;

        case NotesType.Hold:

            HoldNotes holdNotes = (HoldNotes)nextNotes[judgeLane];
            endDifferenceFlame = holdNotes.EndTimingFlame - currentFlame;
            judgeResult        = HoldNoteJudge(differenceFlame, endDifferenceFlame, judgeLane, deltaFlame, judgeData);
            break;

        case NotesType.Barrage:

            BarrageNotes barrageNotes = (BarrageNotes)nextNotes[judgeLane];
            endDifferenceFlame = barrageNotes.EndTimingFlame - currentFlame;
            judgeResult        = BarrageNoteJudge(differenceFlame, endDifferenceFlame, judgeLane, judgeData);
            break;
        }

        return(judgeResult);
    }
    public JudgeType HoldNoteJudge(int differenceFrame, int endDifferenceFlame, int judgeLane, int deltaFlame, JudgeData judgeData)
    {
        HoldNotes judgeNotes  = (HoldNotes)nextNotes[judgeLane];
        JudgeType judgeResult = JudgeType.None;

        JudgeStruct[] judges    = judgeData.judges;
        JudgeStruct   lastJudge = judges[judgeData.judges.Length - 1];
        bool          isPush    = false;

        // 終点が判定ラインを超えたか
        if (endDifferenceFlame <= 0)
        {
            // 始点が押されず、始点の判定がされる前に終点が来た場合はミスにする
            if (!judgeNotes.IsPushedJudge)
            {
                particleController.ShowJudgeText(judgeLineTrans[judgeLane], judgeData.judges[(int)JudgeType.Miss].sprite);
                judgeResult = JudgeType.Miss;
                judgeNotes.IsPushedJudge = true;
            }
            else
            {
                bool isButtonPushed = false;
                if (StaticValue.isAuto)
                {
                    isButtonPushed = endDifferenceFlame >= 0 ? true : false;
                }
                else
                {
                    isButtonPushed = ButtonInput(judgeLane);
                }
                judgeResult = judgeNotes.HoldManage(deltaFlame, isButtonPushed, judgeData.judges);

                if (judgeResult != JudgeType.None)
                {
                    particleController.ShowJudgeText(judgeLineTrans[judgeLane], judgeData.judges[(int)judgeResult].sprite);
                    SetLaneBeamColor(judgeLane, beamColor.beamColors[(int)judgeResult]);

                    if (judgeResult != JudgeType.Miss)
                    {
                        particleController.PlayParticle(judgeLineTrans[judgeLane], (int)judgeResult);
                    }
                }
            }

            SetNextNote(judgeLane);
            return(judgeResult);
        }

        if (differenceFrame <= 0)
        {
            if (1 < (differenceFrame + deltaFlame))
            {
                deltaFlame = Mathf.Abs(differenceFrame);
            }

            bool isButtonPushed = false;
            if (StaticValue.isAuto)
            {
                isButtonPushed = endDifferenceFlame >= 0 ? true : false;
            }
            else
            {
                isButtonPushed = ButtonInput(judgeLane);
            }

            if (isButtonPushed && judgeNotes.IsPushed)
            {
                judgeNotes.SetLineMaterial(lineMaterials[(int)LineMaterialType.Shiny]);
            }
            else if (differenceFrame < -lastJudge.flameRange)
            {
                judgeNotes.SetLineMaterial(lineMaterials[(int)LineMaterialType.Dark]);
            }

            judgeResult = judgeNotes.HoldManage(deltaFlame, isButtonPushed, judgeData.judges);

            if (judgeResult != JudgeType.None)
            {
                particleController.ShowJudgeText(judgeLineTrans[judgeLane], judgeData.judges[(int)judgeResult].sprite);
                SetLaneBeamColor(judgeLane, beamColor.beamColors[(int)judgeResult]);

                if (judgeResult != JudgeType.Miss)
                {
                    particleController.PlayParticle(judgeLineTrans[judgeLane], (int)judgeResult);
                }
            }
        }

        if (StaticValue.isAuto)
        {
            isPush = differenceFrame <= 0 ? true : false;
        }
        else
        {
            isPush = ButtonDownInput(judgeLane);
        }

        // 始点の判定の最大範囲が過ぎた場合は始点の判定をミスにする
        if (!judgeNotes.IsPushedJudge && differenceFrame < -lastJudge.flameRange)
        {
            particleController.ShowJudgeText(judgeLineTrans[judgeLane], judgeData.judges[(int)JudgeType.Miss].sprite);
            judgeResult = JudgeType.Miss;
            judgeNotes.IsPushedJudge = true;
        }

        // ボタンを離してから押さないと反応しないように
        if (isPush && !judgeNotes.IsPushed)
        {
            if (differenceFrame < lastJudge.flameRange)
            {
                judgeNotes.IsPushed = true;
                // 始点の判定をする
                if (!judgeNotes.IsPushedJudge)
                {
                    for (int i = (int)JudgeType.Just; i < judges.Length; i++)
                    {
                        if (Mathf.Abs(differenceFrame) <= judges[i].flameRange)
                        {
                            //輝くノーツの場合は必ず最高判定にする
                            if (judgeNotes.IsShiny)
                            {
                                i = (int)JudgeType.Just;
                                particleController.PlayParticle(judgeLineTrans[judgeLane], 4);
                            }

                            particleController.ShowJudgeText(judgeLineTrans[judgeLane], judges[i].sprite);
                            particleController.PlayParticle(judgeLineTrans[judgeLane], i);

                            SetLaneBeamColor(judgeLane, beamColor.beamColors[i]);

                            MightPlayFastLateAnim(differenceFrame, i);

                            judgeNotes.IsPushedJudge = true;
                            PlayTapSE(NotesType.Hold, judgeLane, judgeNotes.IsShiny);

                            judgeResult = (JudgeType)Enum.ToObject(typeof(JudgeType), i);

                            break;
                        }
                    }
                }
            }
            else
            {
                SetLaneBeamColor(judgeLane, beamColor.noneColor);
            }
        }

        return(judgeResult);
    }