예제 #1
0
 public void Judge(Judgement judgement, LongScript Line, int tapID)
 {
     Judge(judgement);
     Debug.Log("line");
     HoldLine.Remove(tapID);
     Destroy(Line.ParentNote);
     if (Line.EndNote != null)
     {
         Line.EndNote.GetComponent <Notes>().Effect.Judge(judgement);
         NotesLine.Remove(Line.EndNote.GetComponent <Notes>());
         Destroy(Line.EndNote);
     }
     Destroy(Line.gameObject);
 }
예제 #2
0
 public void JudgeMiss(LongScript Long, int tapID) => Judge(Miss, Long, tapID);
예제 #3
0
    void Update()
    {
        if (SongPlay && Music.time / SongSpeed >= Beat + NotesScore[NoteIndex].Duration * 60f / BPM / 2f) //演奏中であるか
        {
            Beat += NotesScore[NoteIndex].Duration * 60f / BPM / 2f;                                      //拍を取得する
            if (NotesScore[NoteIndex].NoteType == LongBegin && LongLine != null)                          //ノーツタイプがロング開始であるか
            {
                Note = Instantiate(NoteObject, NoteArea.transform);                                       //ノーツを生成する
                var NoteScript = InitNotes(Note, NotesScore[NoteIndex].ToType(LongEnd));                  //ロング終了を設定する
                NoteScript.NotesLine = LineDrawing;                                                       //ロング判定ラインを設定する
                LineScript.EndNote   = Note;
                NoteScript.Line      = LineScript;
            }
            NoteIndex++;                                                                       //ノーツの通し番号を更新する
            if (NotesScore[NoteIndex].NoteType != Rest)                                        //休符でないなら
            {
                Note = Instantiate(NoteObject, NoteArea.transform);                            //ノーツを生成する
                var NoteScript = InitNotes(Note, NotesScore[NoteIndex]);                       //ノーツを初期化する
                if (NoteScript.Score.NoteType == LongBegin)                                    //ノーツタイプがロング開始であるか
                {
                    LongLine                    = Instantiate(LongObject, LongArea.transform); //判定ラインを生成する
                    LineDrawing                 = LongLine.GetComponent <UIPointLine>();
                    NoteScript.NotesLine        = LineDrawing;                                 //ノートの判定ラインに設定する
                    LineScript                  = LongLine.GetComponent <LongScript>();
                    LineScript.ParentNote       = Note;
                    LineScript.ParentNoteScript = NoteScript;
                    NoteScript.Line             = LineScript;
                }
            }
            if (NoteIndex >= NotesScore.Count - 1)
            {
                SongPlay = false;                                                //ノーツが終わったら曲を終了する
            }
        }
        if ((Settings.AutoPlay || GameMode == GameMode.ViolinGame) && NotesLine.Count > 0)         //自動スライド
        {
            if (ViolinRect.anchoredPosition.x + NotesLine[0].TargetPosition.x < 0 ||
                ViolinRect.anchoredPosition.x + NotesLine[0].TargetPosition.x > 1600 || Mathf.Abs(dxf - d) > 10)
            {
                dxf = NotesLine[0].TargetPosition.x + 1600 - Settings.Division * 400;
                d   = Mathf.Lerp(d, dxf, 0.1f);
                //	ViolinRect.anchoredPosition + Vector2.right * CanvasRect.rect.width / 2
                //if (ViolinRect.anchoredPosition.x + NotesLine[0].TargetPosition.x < -800
                //	|| ViolinRect.anchoredPosition.x + NotesLine[0].TargetPosition.x > 800)
                ViolinRect.anchoredPosition = new Vector2(Clamp(ViolinRect.sizeDelta.x * (6f / Settings.Division - 1) / 2 - d,
                                                                4800 - (800f / 3 * Result.MusicData.Difficulty[0]) / Settings.Division * 6,
                                                                3200), ViolinRect.anchoredPosition.y);
            }
        }
        if (!SongPlay && (Music.time > Music.clip.length - 2 || !Music.isPlaying))
        {
            if (endtime == 0)
            {
                Violinist.ForEach(v => {
                    var animator     = v.GetComponent <Animator>();
                    animator.enabled = false;
                });
                Ended = true;
                Clap.Play();
                Microphone.End(Microphone.devices[0]);
            }
            endtime += Time.deltaTime;
            if (Ended && endtime >= 4 && endtime < 5)
            {
                Ended = false;
                GameObject.Find("Back").GetComponent <Animator>().SetTrigger("End");
            }
            if (!Ended && endtime >= 5)
            {
                Ended = true;
                if (Settings.AutoPlay)
                {
                    SceneManager.sceneLoaded += SelectSceneLoadedOnPlay;
                    SceneManager.LoadScene("SelectScene");
                }
                else
                {
                    SceneManager.sceneLoaded += ResultSceneLoadedOnPlay;
                    SceneManager.LoadScene("ResultScene");
                }
            }
        }
        if (Settings.AutoPlay)
        {
            return;
        }
        var touchCount = Input.touchCount;

        Touches.AddRange(Enumerable.Range(0, touchCount).Select(i => Input.GetTouch(i)));
        for (var i = 0; i < Touches.Count; i++) //各タップごとに
        {
            var touch  = Touches[i];            //タップ情報を取得する
            var tapPos = ToCanvasPos(touch.position);
            //Debug.Log(touch.fingerId);
            if (!IsPause && GameMode != GameMode.ViolinGame)
            {
                switch (touch.phase)                 //タッチフェーズ
                {
                case TouchPhase.Canceled:
                case TouchPhase.Ended:                         //タップ終了
                    LongScript Long;
                    var        End = AllJudge(n => n.TapID == touch.fingerId && n.Score.NoteType == LongEnd &&
                                              !n.Line.ParentNoteScript.enabled, 0.2f, touch.fingerId);
                    if (End == null && HoldLine.TryGetValue(touch.fingerId, out Long))
                    {
                        ViolinSound.Stop(touch.fingerId);
                        JudgeMiss(Long, touch.fingerId);                             //ホールド中のラインはミスにする
                    }
                    tapPositions.Remove(touch.fingerId);                             //位置を消す
                    break;

                case TouchPhase.Began:                         //タップ開始
                    Vector2 j = new Vector2();
                    if (!tapPositions.TryGetValue(touch.fingerId, out j))
                    {
                        tapPositions.Add(touch.fingerId, tapPos);                                 //タップリストに登録する
                    }
                    Debug.Log($"Tap {NotesLine.Any(n => n.InRange(GetFrequencyFromPosition(tapPos)))}");
                    if (!ViolinRect.rect.Contains(tapPos - ViolinRect.anchoredPosition + Vector2.right * 800))
                    {
                        break;
                    }
                    var Note = AllJudge(n => n.InRange(GetFrequencyFromPosition(tapPos)) &&
                                        (n.Score.NoteType == Tap || n.Score.NoteType == LongBegin), 0.1f, touch.fingerId);
                    if (Note != null && Note.Score.NoteType == LongBegin)                        //ロング開始なら
                    {
                        HoldLine.Add(touch.fingerId, Note.Line);                                 //判定ラインをリストに追加する
                    }
                    break;

                case TouchPhase.Moved:                         //タップ移動
                    if (!Settings.SlideLock ||
                        !ViolinRect.rect.Contains(tapPos - ViolinRect.anchoredPosition + Vector2.right * 800))
                    {
                        var dx = tapPos.x - tapPositions[touch.fingerId].x;
                        ViolinRect.anchoredPosition = new Vector2(Clamp(ViolinRect.anchoredPosition.x + dx,
                                                                        //4800 - 2400f / Settings.Division * 6,
                                                                        4800 - (800f / 3 * Result.MusicData.Difficulty[0]) / Settings.Division * 6,
                                                                        3200), ViolinRect.anchoredPosition.y);
                    }
                    tapPositions[touch.fingerId] = tapPos;                             //タップ更新
                    break;
                }
            }
        }
        if (!IsPause)
        {
            Touches = new List <Touch>();
        }
    }