コード例 #1
0
        //先読みかけておく
        void UpdatePreLoadFiles(int commandIndex, int fileCount)
        {
            HashSet <AssetFile> lastPreloadFileSet = preloadFileSet;

            preloadFileSet = new HashSet <AssetFile>();
            while (true)
            {
                ++commandIndex;
                AdvCommand command = scearioData.GetCommand(commandIndex);
                if (null == command)
                {
                    break;
                }

                if (command.LoadFileList != null)
                {
                    foreach (AssetFile file in command.LoadFileList)
                    {
                        preloadFileSet.Add(file);
                    }
                }
                if (preloadFileSet.Count > fileCount)
                {
                    break;
                }
            }
            ;

            //リストに従って先読み
            foreach (AssetFile file in preloadFileSet)
            {
                AssetFileManager.Preload(file, this);
                //もうプリロードされなくなったリストを作るために
                if (lastPreloadFileSet.Contains(file))
                {
                    lastPreloadFileSet.Remove(file);
                }
            }
            //直前の先読みファイルは参照を減算しておく
            foreach (AssetFile file in lastPreloadFileSet)
            {
                file.Unuse(this);
            }
        }
コード例 #2
0
        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();
        }