private void OnProviderLoaded(SavegameData savegameData)
        {
            isBusy = false;

            T savegame = new T();

            savegame.Initialize(savegameData.Savegame, savegameData.Metadata);

            if (OnLoadComplete != null)
            {
                OnLoadComplete(savegame);
            }
        }
Пример #2
0
        public virtual void Write <T> (SavegameData pData, Action OnComplete, Action <Exception, int> OnError) where T : ISavegame
        {
            if (!Directory.Exists(mPath))
            {
                Directory.CreateDirectory(mPath);
            }

            UpdateMetadataList(pData.Metadata);

            WriteMetadata <T>(mPath + mMetadataFilename, null);

            string target = mPath + mFilenameTemplate;

            target = string.Format(target.ToString(), pData.Metadata.Id);

            WriteSavegame(target, pData.Savegame, OnComplete);
        }
Пример #3
0
        void ReadSavegame(string pSource, int ID, Action <SavegameData> OnComplete)
        {
            var    reader = new StreamReader(pSource);
            string result = reader.ReadToEnd();

            reader.Close();

            Metadata metadata = GetSavegameMetadata(ID);

            if (metadata == null)
            {
                throw new KeyNotFoundException("Metadata not found for ID: " + ID);
            }

            SavegameData sgData = new SavegameData(metadata, result);

            if (OnComplete != null)
            {
                OnComplete(sgData);
            }
        }
Пример #4
0
        IEnumerator ReadSavegameAsync(string pSource, int ID, Action <SavegameData> OnComplete)
        {
            var progress = IOBridge.Storage.Load(pSource);

            while (!progress.IsDone)
            {
                yield return(true);
            }

            Metadata metadata = GetSavegameMetadata(ID);

            if (metadata == null)
            {
                throw new KeyNotFoundException("Metadata not found for ID: " + ID);
            }

            SavegameData sgData = new SavegameData(metadata, progress.GetContent());

            if (OnComplete != null)
            {
                OnComplete(sgData);
            }
        }