Beispiel #1
0
        public void Load(Action onLoadComplete)
        {
            AddRWOperation(() =>
            {
                var path = CompletePath;

                //Exists ?
                if (Saves.Exists(path))
                {
                    //Load and apply
                    object graph = Saves.InstantLoad(path);
                    _OverwriteLocalData(graph);

                    if (onLoadComplete != null)
                    {
                        onLoadComplete();
                    }
                }
                else
                {
                    //Nouveau fichier !
                    _SetDefaultLocalData();

                    Save(onLoadComplete);
                }

                CompleteRWOperation();
            });
        }
Beispiel #2
0
        public void SaveAsync(Action onSaveComplete)
        {
            AddRWOperation(() =>
            {
                Action onComplete = () =>
                {
                    if (onSaveComplete != null)
                    {
                        onSaveComplete();
                    }

                    CompleteRWOperation();
                };

                var data = GetLocalData();
                if (data != null)
                {
                    Saves.ThreadSave(CompletePath, data, onComplete);
                }
                else
                {
                    onComplete();
                }
            });
        }
Beispiel #3
0
        public void LoadAsync(Action onLoadComplete)
        {
            AddRWOperation(() =>
            {
                var path = CompletePath;

                //Exists ?
                if (Saves.Exists(path))
                {
                    Saves.ThreadLoad(path,
                                     delegate(object graph)
                    {
                        _OverwriteLocalData(graph);

                        if (onLoadComplete != null)
                        {
                            onLoadComplete();
                        }

                        CompleteRWOperation();
                    });
                }
                else
                {
                    //Nouveau fichier !
                    _SetDefaultLocalData();
                    SaveAsync(onLoadComplete);

                    CompleteRWOperation();
                }
            });
        }
Beispiel #4
0
        public void ClearSave(Action onComplete)
        {
            AddRWOperation(() =>
            {
                Saves.Delete(CompletePath);
                _SetDefaultLocalData();

                if (onComplete != null)
                {
                    onComplete();
                }

                CompleteRWOperation();
            });
        }
Beispiel #5
0
        public void Save(Action onSaveComplete)
        {
            AddRWOperation(() =>
            {
                var data = GetLocalData();
                if (data != null)
                {
                    Saves.InstantSave(CompletePath, data);
                }

                if (onSaveComplete != null)
                {
                    onSaveComplete();
                }

                CompleteRWOperation();
            });
        }