/// <summary> /// 指定シナリオラベルの指定ページのコマンドインデックスを取得 /// </summary> /// <param name="scenarioLabel">シナリオラベル</param> /// <param name="page">ページ</param> /// <returns>ページのコマンドインデックス</returns> public int SeekPageIndex(string scenarioLabel, int page) { int index = 0; if (Name == scenarioLabel) { //シナリオ名そのものだった場合は一番最初から index = 0; } else { //シナリオラベルをシーク while (true) { AdvCommand command = GetCommand(index); if (null == GetCommand(index)) { Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.NotFoundScnarioLabel, scenarioLabel)); return(0); } if (command.GetScenarioLabel() == scenarioLabel) { break; } ++index; } } if (page < 0) { //シナリオラベル冒頭 return(index); } int pageCount = 0; //シナリオラベルからの指定のページまでシーク while (true) { AdvCommand command = GetCommand(index); if (null == command) { //指定のページ数がなかったので、ここまでで終了 return(index - 1); } if (command.IsTypePageEnd()) { if (pageCount >= page) { return(index); } ++pageCount; } ++index; } }
//シナリオラベル区切りのデータを作成 void MakeScanerioLabelData(List <AdvCommand> commandList) { if (commandList.Count <= 0) { return; } //最初のラベル区切りデータは自身の名前(シート名) AdvScenarioLabelData data = new AdvScenarioLabelData(Name, null); int commandIndex = 0; while (true) { //重複してないかチェック if (IsContainsScenarioLabel(data.ScenaioLabel)) { Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.RedefinitionScenarioLabel, data.ScenaioLabel, DataGridName)); break; } scenarioLabelData.Add(data); //コマンドを追加 while (commandIndex < commandList.Count) { AdvCommand command = commandList[commandIndex]; //シナリオラベルがあるので、終了 if (!string.IsNullOrEmpty(command.GetScenarioLabel())) { break; } data.AddCommand(command); ///このシナリオからリンクするジャンプ先のシナリオラベルを取得 string[] jumpLabels = command.GetJumpLabels(); if (jumpLabels != null) { foreach (var jumpLabel in jumpLabels) { jumpScenarioData.Add(new AdvScenarioJumpData(jumpLabel, command.RowData)); } } ++commandIndex; } //ページデータの初期化処理 data.InitPages(); if (commandIndex >= commandList.Count) { break; } data = new AdvScenarioLabelData(commandList[commandIndex].GetScenarioLabel(), commandList[commandIndex] as AdvCommandScenarioLabel); ++commandIndex; } }
IEnumerator CoStartScenario(AdvEngine engine, string label, int page, string gallerySceneLabel) { if ((debugOutPut & DebugOutPut.Log) == DebugOutPut.Log) { Debug.Log("Jump : " + label + " :" + page); } if (!engine.DataManager.IsReadySettingData) { Debug.LogError("Not ready SettingData"); } isWaitLoading = true; while (!engine.DataManager.IsLoadEndScenarioLabel(label)) { yield return(0); } scearioData = engine.DataManager.FindScenarioData(label); Reset(); //指定のページまでジャンプ currentIndex = scearioData.SeekPageIndex(label, page); currentScenarioLabel = label; currentPage = (page < 0) ? page : page - 1; currentGallerySceneLabel = gallerySceneLabel; engine.Page.BeginPage(currentScenarioLabel, currentPage); UpdateSceneGallery(currentScenarioLabel, engine); isWaitLoading = false; if (preloadFileSet.Count > 0) { Debug.LogError("Error Preload Clear"); } AdvCommand command = scearioData.GetCommand(currentIndex); while (null != command) { //ロード command.Load(); //プリロードを更新 if (command.IsExistLoadFile()) { UpdatePreLoadFiles(currentIndex, MAX_PRELOAD_FILES); } //ロード待ち while (!command.IsLoadEnd()) { isWaitLoading = true; yield return(0); } isWaitLoading = false; ///シナリオラベルの更新 if (!string.IsNullOrEmpty(command.GetScenarioLabel())) { currentScenarioLabel = command.GetScenarioLabel(); currentPage = -1; ///ページ開始処理 engine.Page.BeginPage(currentScenarioLabel, currentPage); UpdateSceneGallery(currentScenarioLabel, engine); } //コマンド実行 if ((debugOutPut & DebugOutPut.Log) == DebugOutPut.Log) { Debug.Log("Command : " + command.GetType()); } command.DoCommand(engine); ///ページ末端・オートセーブデータを更新 if (command.IsTypePageEnd()) { ++currentPage; ///ページ開始処理 engine.Page.BeginPage(currentScenarioLabel, currentPage); engine.SaveManager.UpdateAutoSaveData(engine); } //コマンド実行後にファイルをアンロード command.Unload(); //コマンドの処理待ち while (command.Wait(engine)) { if ((debugOutPut & DebugOutPut.Waiting) == DebugOutPut.Waiting) { Debug.Log("Wait..." + command.GetType()); } yield return(0); } if ((debugOutPut & DebugOutPut.CommandEnd) == DebugOutPut.CommandEnd) { Debug.Log("End :" + command.GetType() + " " + label + ":" + page); } ///改ページ処理 if (command.IsTypePageEnd()) { engine.SystemSaveData.ReadData.AddReadPage(engine.Page.ScenarioLabel, engine.Page.PageNo); engine.Page.EndPage(); } //次のコマンドへ do { ++currentIndex; command = scearioData.GetCommand(currentIndex); //ifスキップチェック if (!ifManager.CheckSkip(command)) { break; } else { ///ページ末端 if (command.IsTypePageEnd()) { ++currentPage; } } } while (true); } EndScenario(); }