public MusicDTOFormatter(MusicListItemJson item, MusicInf inf, MusicOldDTO data)
 {
     this.item = item;
     this.inf  = inf;
     old_data  = data;
 }
 public MusicDTOFormatter(MusicListItemJson item, MusicInf inf, MusicDTO.EditData data)
 {
     this.item = item;
     this.inf  = inf;
     dto_data  = data;
 }
Exemple #3
0
    protected override void Load()
    {
        SimpleMusicData musicData;
        MusicInf        inf;

        MusicDTO.EditData data;
        MusicOldDTO       oldData;
        GameObject        gameObject     = GameObject.Find("LocalResources");
        LocalResources    localResources = gameObject.GetComponent <LocalResources>();
        string            folder         = "/music";

#if UNITY_EDITOR
        folder = "/resources/music";
#endif

        if (System.IO.Directory.Exists(@Application.dataPath + folder))
        {
            string[] directories = System.IO.Directory.GetDirectories(@Application.dataPath + "/resources/music", "*");
            string   json;
            for (int i = 0; i < directories.Length; i++)
            {
                // id,pathを読み込む
                MusicListItemJson item;
                item    = new MusicListItemJson();
                item.id = startId + i;

                if (System.IO.Directory.Exists(directories[i]))
                {
                    if (System.IO.File.Exists(directories[i] + "/info.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/info");
                        inf  = JsonUtility.FromJson <MusicInf>(json);
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/music.wav"))
                    {
                        item.path = directories[i];
                    }
                    else if (System.IO.File.Exists(directories[i] + "/music.mp3"))
                    {
                        item.path = directories[i];
                    }
                    else
                    {
                        break;
                    }
                    if (System.IO.File.Exists(directories[i] + "/score.json"))
                    {
                        json = (string)localResources.GetLoadFile(directories[i] + "/score");

                        // 譜面情報を読み込む
                        if (inf.score_ver == 1)
                        {
                            data = JsonUtility.FromJson <MusicDTO.EditData>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, data);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else if (inf.score_ver == 0)
                        {
                            oldData = JsonUtility.FromJson <MusicOldDTO>(json);
                            MusicDTOFormatter musicDTOFormatter = new MusicDTOFormatter(item, inf, oldData);
                            musicData = musicDTOFormatter.ToSimpleMusicData();
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    musicDataList.Add(musicData);
                }
            }
        }
    }