Пример #1
0
    public void Load(MusicNames MusicName, Levels level)
    {
        NotesManager notesManager = (NotesManager)FindObjectOfType(typeof(NotesManager));
        MoveManager  moveManager  = (MoveManager)FindObjectOfType(typeof(MoveManager));
        JudgeScript  judgeScript  = (JudgeScript)FindObjectOfType(typeof(JudgeScript));

        string folderName = "Data/" + MusicName.ToString() + "/";

        TextAsset    musicData = Resources.Load <TextAsset>(folderName + tuneData);
        StringReader sr        = new StringReader(musicData.text);

        while (sr.Peek() != -1)
        {
            string        _str = sr.ReadLine();
            string[]      str  = _str.Split(',');
            TuneDataIndex tuneDataIndex;
            Enum.TryParse <TuneDataIndex>(str[0], out tuneDataIndex);
            switch (tuneDataIndex)
            {
            case TuneDataIndex.NAME:
                musicName = str[1];
                break;

            case TuneDataIndex.BPM:
                bpm = float.Parse(str[1]);
                break;

            case TuneDataIndex.OFFSET:
                offset = float.Parse(str[1]);
                break;
            }
        }
        notesManager.SetBPM(bpm);
        notesManager.SetOffset(offset);

        TextAsset notesData = Resources.Load <TextAsset>(folderName + level.ToString() + "NotesData");

        notesManager.Load(notesData);
        AudioClip clip = Resources.Load <AudioClip>(folderName + clipName);

        moveManager.Init();
        moveManager.SetClip(clip);
        judgeScript.Init();

        moveManager.MusicStart();
    }