Esempio n. 1
0
        public void LoadFromGameKitData(UM_iSavedGameMetadata game, bool parseMeta, Action <UM_SavedGameDataLoadResult> callback)
        {
            var isn_meta = (UM_IOSSavedGameMetadata)game;

            ISN_GKLocalPlayer.LoadGameData(isn_meta.NativeMeta, (result) => {
                UM_SavedGameDataLoadResult loadResult;
                if (result.IsSucceeded)
                {
                    if (parseMeta)
                    {
                        var meta = new UM_SaveInfo();
                        meta.SetProgressValue(BitConverter.ToInt64(result.BytesArrayData, 0));
                        meta.SetPlayedTimeMillis(BitConverter.ToInt64(result.BytesArrayData, 8));

                        var userData = new byte[result.BytesArrayData.Length - 16];
                        Array.Copy(result.BytesArrayData, 16, userData, 0, userData.Length);
                        loadResult = new UM_SavedGameDataLoadResult(userData, meta);
                    }
                    else
                    {
                        loadResult = new UM_SavedGameDataLoadResult(result.BytesArrayData, new UM_SaveInfo());
                    }
                }
                else
                {
                    loadResult = new UM_SavedGameDataLoadResult(result.Error);
                }

                callback.Invoke(loadResult);
            });
        }
Esempio n. 2
0
        public void SaveGameWithMeta(string name, byte[] data, UM_SaveInfo meta, Action <SA_Result> callback)
        {
            var extendedData = Combine(BitConverter.GetBytes(meta.ProgressValue),
                                       BitConverter.GetBytes(meta.PlayedTime),
                                       data);

            SaveGame(name, extendedData, callback);
        }
        public void SaveGameWithMeta(string name, byte[] data, UM_SaveInfo meta, Action <SA_Result> callback)
        {
            var androidMeta = new AN_SnapshotMetadataChange.Builder();

            androidMeta.SetProgressValue(meta.ProgressValue);
            androidMeta.SetPlayedTimeMillis(meta.PlayedTime);
            androidMeta.SetDescription(meta.Description);

            //we know this is going to by synchronous
            meta.LoadCoverImage((texture) =>
            {
                androidMeta.SetCoverImage(texture);
            });

            SaveAndroidSnapShotGame(name, data, androidMeta.Build(), callback);
        }
Esempio n. 4
0
        public void LoadFromPlayerPrefs(UM_iSavedGameMetadata game, bool parseMeta, Action <UM_SavedGameDataLoadResult> callback)
        {
            var editorGamesList = LoadSavesList();
            var editorGame      = editorGamesList.GetByName(game.Name);

            UM_SavedGameDataLoadResult loadResult;

            if (editorGame != null)
            {
                var BytesArrayData = editorGame.GameData.ToBytes();
                if (parseMeta)
                {
                    var meta = new UM_SaveInfo();
                    meta.SetProgressValue(BitConverter.ToInt64(BytesArrayData, 0));
                    meta.SetPlayedTimeMillis(BitConverter.ToInt64(BytesArrayData, 8));

                    var userData = new byte[BytesArrayData.Length - 16];
                    Array.Copy(BytesArrayData, 16, userData, 0, userData.Length);
                    loadResult = new UM_SavedGameDataLoadResult(userData, meta);
                }
                else
                {
                    loadResult = new UM_SavedGameDataLoadResult(BytesArrayData, new UM_SaveInfo());
                }
            }
            else
            {
                var error = new SA_Error(100, "Saved game with name: " + game.Name + " wasn't found");
                loadResult = new UM_SavedGameDataLoadResult(error);
            }

            EditorSaveGames(editorGamesList);

            SA_Coroutine.WaitForSeconds(1.5f, () =>
            {
                callback.Invoke(loadResult);
            });
        }
 public UM_SavedGameDataLoadResult(byte[] data, UM_SaveInfo meta)
 {
     m_Data = data;
     m_Meta = meta;
 }