private IEnumerator checkUpdate() { setInformationText("MainSpreadSheet通信開始"); yield return(null); string mainSpreadSheet = this.networkManager.RequestMainSpreadSheet(); setInformationText("MainSpreadSheet通信成功"); yield return(null); ResponseObjectMasterStage masterStage = JsonFx.Json.JsonReader.Deserialize <ResponseObjectMasterStage>(mainSpreadSheet); masterStage.SetupEntry(); RhythmGameDataManager.masterStageRecordDataList = masterStage.GetDataList(); if (RhythmGameDataManager.masterStageRecordDataList != null) { yield return(StartCoroutine(downloadMusicScoreListIfNeeded(masterStage))); } this.titleRoot.SetActive(false); this.menuRoot.SetActive(true); yield return(null); }
private IEnumerator downloadMusicScoreListIfNeeded(ResponseObjectMasterStage masterStage) { setInformationText("SubSpreadSheet一覧取得の通信開始"); yield return(null); Dictionary <string, string> spreadSheetInfoDictionary = SpreadSheetInfoUtility.GetSpreadSheetInfoDictionary(this.networkManager); setInformationText("SubSpreadSheet一覧取得の通信成功"); yield return(null); UpdateCheckSaveDataList updateCheckSaveDataList = DataManager.Load <UpdateCheckSaveDataList>(DataManager.UPDATE_INFO); if (updateCheckSaveDataList == null) { updateCheckSaveDataList = new UpdateCheckSaveDataList(); updateCheckSaveDataList.dataList = new List <UpdateCheckSaveData>(); } // 保存されている譜面を読み込み MusicScoreSaveDataDictionary musicScoreSaveDataDictionary = DataManager.Load <MusicScoreSaveDataDictionary>(DataManager.MUSIC_SCORE_DATA); if (musicScoreSaveDataDictionary != null && musicScoreSaveDataDictionary.dataDictionary != null) { setInformationText("保存されている譜面を読み込み開始"); foreach (string stageName in musicScoreSaveDataDictionary.dataDictionary.Keys) { setInformationText("保存されている譜面を読み込み " + stageName); MusicScoreSaveData musicScoreSaveData = musicScoreSaveDataDictionary.dataDictionary[stageName]; if (RhythmGameDataManager.musicScoreDictionary.ContainsKey(stageName) == false) { RhythmGameDataManager.musicScoreDictionary.Add(stageName, musicScoreSaveData.musicScoreRecordDataList); } } } foreach (MasterStageRecordData recordData in RhythmGameDataManager.masterStageRecordDataList.dataList) { bool isSkip = false; UpdateCheckSaveData updateCheckSaveData = null; // 保存されているデータバージョンと同じ譜面ならスキップ foreach (UpdateCheckSaveData data in updateCheckSaveDataList.dataList) { if (data.stageName == recordData.stageName) { if (data.version == recordData.version) { // 実際に譜面がなかった場合はスキップしない if (RhythmGameDataManager.musicScoreDictionary.ContainsKey(data.stageName) == false) { isSkip = false; Debug.Log_blue("譜面がなかったので譜面読み込みをスキップしない " + recordData.stageName, this); } else { isSkip = true; } } updateCheckSaveData = data; break; } } if (isSkip) { continue; } // バージョンを更新 if (updateCheckSaveData != null) { setInformationText("バージョン更新 " + recordData.stageName); Debug.Log_blue("バージョンを更新 " + recordData.stageName + ", version = " + recordData.version, this); updateCheckSaveData.version = recordData.version; } else { setInformationText("新規譜面を登録 " + recordData.stageName); Debug.Log_blue("新規譜面を登録 " + recordData.stageName + ", version = " + recordData.version, this); updateCheckSaveData = new UpdateCheckSaveData(); updateCheckSaveData.stageName = recordData.stageName; updateCheckSaveData.bpm = recordData.bpm; updateCheckSaveData.version = recordData.version; updateCheckSaveDataList.dataList.Add(updateCheckSaveData); } setInformationText("譜面読み込み中" + recordData.stageName); yield return(null); string sheetId = spreadSheetInfoDictionary[recordData.stageName]; string url = this.networkManager.GetSpreadSheetURLWithSheetId(sheetId); string result = this.networkManager.Request(url, recordData.stageName); ResponseObjectMusicScore masterMusicScore = JsonFx.Json.JsonReader.Deserialize <ResponseObjectMusicScore>(result); masterMusicScore.SetupEntry(); MasterMusicScoreRecordDataList scoreRecordDataList = masterMusicScore.GetDataList(); if (RhythmGameDataManager.musicScoreDictionary.ContainsKey(recordData.stageName)) { RhythmGameDataManager.musicScoreDictionary.Remove(recordData.stageName); } RhythmGameDataManager.musicScoreDictionary.Add(recordData.stageName, scoreRecordDataList); } DataManager.Save(DataManager.UPDATE_INFO, updateCheckSaveDataList); #region 譜面の保存 MusicScoreSaveDataDictionary saveTarget = new MusicScoreSaveDataDictionary(); saveTarget.dataDictionary = new Dictionary <string, MusicScoreSaveData>(); foreach (string key in RhythmGameDataManager.musicScoreDictionary.Keys) { MasterMusicScoreRecordDataList recordList = RhythmGameDataManager.musicScoreDictionary[key]; MusicScoreSaveData saveData = new MusicScoreSaveData(); saveData.musicScoreRecordDataList = recordList; saveTarget.dataDictionary.Add(key, saveData); } DataManager.Save(DataManager.MUSIC_SCORE_DATA, saveTarget); #endregion // 譜面の保存 setInformationText("譜面の読み込み完了"); yield return(null); StartCoroutine(setupMusicUI()); }