Example #1
0
 public void OpenWithManualConflictResolution(string filename, GooglePlayGames.BasicApi.DataSource source, bool prefetchDataOnConflict, ConflictCallback conflictCallback, Action <SavedGameRequestStatus, ISavedGameMetadata> completedCallback)
 {
     Misc.CheckNotNull <string>(filename);
     Misc.CheckNotNull <ConflictCallback>(conflictCallback);
     Misc.CheckNotNull <Action <SavedGameRequestStatus, ISavedGameMetadata> >(completedCallback);
     conflictCallback  = this.ToOnGameThread(conflictCallback);
     completedCallback = NativeSavedGameClient.ToOnGameThread <SavedGameRequestStatus, ISavedGameMetadata>(completedCallback);
     if (!NativeSavedGameClient.IsValidFilename(filename))
     {
         Logger.e("Received invalid filename: " + filename);
         completedCallback(SavedGameRequestStatus.BadInputError, (ISavedGameMetadata)null);
     }
     else
     {
         this.InternalManualOpen(filename, source, prefetchDataOnConflict, conflictCallback, completedCallback);
     }
 }
Example #2
0
        public void OpenWithAutomaticConflictResolution(string filename, GooglePlayGames.BasicApi.DataSource source, ConflictResolutionStrategy resolutionStrategy, Action <SavedGameRequestStatus, ISavedGameMetadata> callback)
        {
            Misc.CheckNotNull <string>(filename);
            Misc.CheckNotNull <Action <SavedGameRequestStatus, ISavedGameMetadata> >(callback);
            callback = NativeSavedGameClient.ToOnGameThread <SavedGameRequestStatus, ISavedGameMetadata>(callback);
            if (!NativeSavedGameClient.IsValidFilename(filename))
            {
                Logger.e("Received invalid filename: " + filename);
                callback(SavedGameRequestStatus.BadInputError, (ISavedGameMetadata)null);
            }
            else
            {
                this.OpenWithManualConflictResolution(filename, source, false, (ConflictCallback)((resolver, original, originalData, unmerged, unmergedData) =>
                {
                    switch (resolutionStrategy)
                    {
                    case ConflictResolutionStrategy.UseLongestPlaytime:
                        if (original.TotalTimePlayed >= unmerged.TotalTimePlayed)
                        {
                            resolver.ChooseMetadata(original);
                            break;
                        }
                        resolver.ChooseMetadata(unmerged);
                        break;

                    case ConflictResolutionStrategy.UseOriginal:
                        resolver.ChooseMetadata(original);
                        break;

                    case ConflictResolutionStrategy.UseUnmerged:
                        resolver.ChooseMetadata(unmerged);
                        break;

                    default:
                        Logger.e("Unhandled strategy " + (object)resolutionStrategy);
                        callback(SavedGameRequestStatus.InternalError, (ISavedGameMetadata)null);
                        break;
                    }
                }), callback);
            }
        }