Beispiel #1
0
    IEnumerator playMusicGame()
    {
        Debug.Log("StartCoroutine");
        float CreateTime = Notes2Time(96, mapdata.bpm, 0) / HiSpeed;

        Debug.Log("CreateTime:" + CreateTime);
        float playTime   = 0;
        int   NextCreate = 0;
        bool  MapEnd     = false;

        while (true)
        {
            //音源再生待機→再生まで
            if (music.isPlaying)
            {
                playTime = music.time - NoteOffset;
            }
            else
            {
                playTime += fps;
                if (!MapEnd && playTime > 0 - NoteOffset)
                {
                    Debug.Log("MusicStart");
                    music.Play();
                }
            }

            //鍵盤を押したときの処理
            for (int key = 0; key < 6; key++)
            {
                if (Input.GetKey(KeyConfig[key]) != isOnKey[key])
                {
                    //Debug.Log(i);
                    if (isOnKey[key])
                    {
                        draw.TurnOff(key);
                        isOnKey[key] = false;
                    }
                    else
                    {
                        int judgeResult = judge.OnKey(key, playTime);
                        draw.TurnOn(key, judgeResult);
                        if (judgeResult > 0)
                        {
                            breakdown[judgeResult]++;
                            SkinScore  += BaseScore * ScoreRatio[judgeResult - 1];
                            BonusScore += BaseScore * ComboRatio * (++Combo);
                            Score       = (int)SkinScore + (int)BonusScore;
                            canvas.Chenge(Score, Combo);
                        }
                        isOnKey[key] = true;
                    }
                }
            }

            //譜面読み込み・ノーツ生成処理
            if (!MapEnd  && playTime + CreateTime > directMap[NextCreate].timing)
            {
                for (int i = 0; i < 6; i++)
                {
                    if (directMap[NextCreate].note[i] == 1)
                    {
                        draw.CreateNotes(NextCreate, i, CreateTime);
                    }
                }
                NextCreate++;
                if (directMap[NextCreate].note[0] < 0)
                {
                    MapEnd = true;
                }
            }

            //ミス判定
            if (judge.CheckMiss(playTime))
            {
                breakdown[0]++;
                if (MaxCombo < Combo)
                {
                    MaxCombo = Combo;
                }
                Combo = 0;
                canvas.Chenge(Score, Combo);
            }

            //終了処理(中断はEscキー)
            if (Input.GetKey(KeyConfig[7]) || (MapEnd && !music.isPlaying))
            {
                yield return(StartCoroutine("EndMusic"));

                Debug.Log("END");
                break;
            }

            yield return(new WaitForSeconds(fps));
        }
        carrier.PassResult(Score, MaxCombo, AllTarget, (int)SkinScore, (int)BonusScore, breakdown);
        SceneManager.LoadScene("Result");
        yield break;
    }