Esempio n. 1
0
            IEnumerator OnOpenServiceTask(Asset.SubTaskHandle sth,
                                          Action loadStart,
                                          Func <bool> loadDone = null)
            {
                var signal = sth.Signal;

                if (CancellableSignal.IsCancelled(signal))
                {
                    yield break;
                }

                try
                {
                    loadStart();
                }
                catch (Exception e)
                {
                    Debug.LogWarning(string.Format("SERVICEMODEL:WARN:OPEN_SERVICE_EXCEPT:{0}", e));
                    sth.SetFailed(e);
                    yield break;
                }

                if (null != loadDone)
                {
                    bool isDone = false;
                    do
                    {
                        try
                        {
                            isDone = loadDone();
                        }
                        catch (Exception e)
                        {
                            Debug.LogWarning(string.Format("SERVICEMODEL:WARN:OPEN_SERVICE_EXCEPT#2:{0}", e));
                            sth.SetFailed(e);
                            yield break;
                        }

                        yield return(null);

                        if (CancellableSignal.IsCancelled(signal))
                        {
                            yield break;
                        }
                    }while (!isDone);
                }
                else
                {
                    yield return(null);

                    if (CancellableSignal.IsCancelled(signal))
                    {
                        yield break;
                    }
                }

                sth.Complete();
            }
Esempio n. 2
0
            internal IEnumerator OpenSheetTask(Asset.SubTaskHandle sth)
            {
                var signal = sth.Signal;

                if (CancellableSignal.IsCancelled(signal))
                {
                    yield break;
                }

                var sheetInfos = new SheetInfo[]
                {
                    //this.CreateSheetInfo<long, GameConfigData   >(this.OnOpenSheets_GameConfigData      ),
                    //this.CreateSheetInfo<long, RegionData       >(this.OnOpenSheets_RegionData          ),
                    //this.CreateSheetInfo<long, ComposerData     >(this.OnOpenSheets_ComposerData        ),
                    //this.CreateSheetInfo<long, MusicData        >(this.OnOpenSheets_MusicData           ),
                    //this.CreateSheetInfo<long, BgmData          >(this.OnOpenSheets_BgmData             ),
                    //this.CreateSheetInfo<long, MatineeData      >(this.OnOpenSheets_MatineeData         ),
                    //this.CreateSheetInfo<long, StarData         >(this.OnOpenSheets_StarData            ),
                    //this.CreateSheetInfo<long, JudgementData    >(this.OnOpenSheets_JudgementData       ),
                    //this.CreateSheetInfo<long, Concours4KeyData >(this.OnOpenSheets_Concours4KeyData    ),
                    //this.CreateSheetInfo<long, Concours6KeyData >(this.OnOpenSheets_Concours6KeyData    ),
                    //this.CreateSheetInfo<long, PianoData        >(this.OnOpenSheets_PianoData           ),
                    this.CreateSheetInfo <long, UnitData>(this.OnOpenSheets_UnitData),
                };

                var progressStride     = 1f / sheetInfos.Length;
                var progressStrideHalf = progressStride * 0.5f;
                var progress           = 0f;

                for (int n = 0, cnt = sheetInfos.Length; n < cnt; ++n)
                {
                    var si     = sheetInfos[n];
                    var source = Resources.Load <TextAsset>(string.Format("Data/{0}", si.sheetname));
                    if (!source)
                    {
                        Debug.LogError(string.Format("SERVICEMODEL:SHEET_NOT_FOUND_ERROR:{0}", si.sheetname));
                    }
                    sth.SetProgress(progress + progressStrideHalf);
                    yield return(null);

                    if (CancellableSignal.IsCancelled(signal))
                    {
                        yield break;
                    }

                    si.parseFunc(si, source);
                    sth.SetProgress(progress += progressStride);
                    yield return(null);

                    if (CancellableSignal.IsCancelled(signal))
                    {
                        yield break;
                    }
                }

                sth.Complete();
            }