public async void Save(byte[] data) { var result = await GamesClass.Snapshots.Open(client, SavedGameFileName, true).AsAsync <ISnapshotsOpenSnapshotResult>(); var code = result.Status.StatusCode; if (code == STATUS_SNAPSHOT_CONFLICT) { var conflictId = result.ConflictId; var serverSnapshot = result.Snapshot; var conflictedSnapshot = result.ConflictingSnapshot; result = await GamesClass.Snapshots.ResolveConflict(client, conflictId, conflictedSnapshot).AsAsync <ISnapshotsOpenSnapshotResult>(); } //On sauve ISnapshotMetadataChange change = new SnapshotMetadataChangeBuilder() .SetDescription("KillTeamManager") .SetPlayedTimeMillis(DateTime.Now.Ticks) .Build(); using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutLong("lastSave", change.PlayedTimeMillis.LongValue()); e.Commit(); } } result.Snapshot.SnapshotContents.WriteBytes(dataToSave); await GamesClass.Snapshots.CommitAndClose(client, result.Snapshot, change); }
public async static Task <long> Update(long Gold, long Stage, float Damage, GoogleApiClient googleApiClient) { ISnapshot snapshot = await GetSnapshot(googleApiClient); snapshot.SnapshotContents.WriteBytes(CloudCopyState.GetData(Gold, Stage, Damage)); SnapshotMetadataChangeBuilder metadataChangeBuilder = new SnapshotMetadataChangeBuilder( ); metadataChangeBuilder.SetCoverImage(Assets.Icon); metadataChangeBuilder.SetDescription($"Time Titan Stage {Stage}, {Gold} Gold, {Damage} Damage"); metadataChangeBuilder.SetProgressValue(Stage); ISnapshotMetadataChange metadataChange = metadataChangeBuilder.Build( ); ISnapshotsCommitSnapshotResult commitSnapshotResult = await GamesClass.Snapshots.CommitAndCloseAsync(googleApiClient, snapshot, metadataChange); return(commitSnapshotResult.SnapshotMetadata.LastModifiedTimestamp); }
internal NativeSnapshotMetadataChange Build() { return(NativeSnapshotMetadataChange.FromPointer(SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_Create(this.SelfPtr()))); }
internal NativeSnapshotMetadataChange.Builder SetCoverImageFromPngData(byte[] pngData) { Misc.CheckNotNull <byte[]>(pngData); SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_SetCoverImageFromPngData(this.SelfPtr(), pngData, new UIntPtr((ulong)pngData.LongLength)); return(this); }
internal NativeSnapshotMetadataChange.Builder SetPlayedTime(ulong playedTime) { SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_SetPlayedTime(this.SelfPtr(), playedTime); return(this); }
internal NativeSnapshotMetadataChange.Builder SetDescription(string description) { SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_SetDescription(this.SelfPtr(), description); return(this); }
protected override void CallDispose(HandleRef selfPointer) { SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_Dispose(selfPointer); }
internal Builder() : base(SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_Construct()) { }
public async Task <byte[]> Synchro(byte[] data) { if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M) { if (Android.App.Application.Context.CheckSelfPermission(Manifest.Permission.Internet) != (int)Permission.Granted || Android.App.Application.Context.CheckSelfPermission(Manifest.Permission.GetAccounts) != (int)Permission.Granted) { Android.Support.V4.App.ActivityCompat.RequestPermissions(this.activity, new string[] { Manifest.Permission.Internet, Manifest.Permission.GetAccounts, }, 0); return(null); } } long lastSave = 0; using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { lastSave = settings.GetLong("lastSave", 0); } try { if (data != null) { dataToSave = data; } if (!IsConnected()) { SignIn(); } else { var result = await GamesClass.Snapshots.Open(client, SavedGameFileName, true).AsAsync <ISnapshotsOpenSnapshotResult>(); var code = result.Status.StatusCode; if (code == STATUS_SNAPSHOT_CONFLICT) { var conflictId = result.ConflictId; var serverSnapshot = result.Snapshot; var conflictedSnapshot = result.ConflictingSnapshot; result = await GamesClass.Snapshots.ResolveConflict(client, conflictId, conflictedSnapshot).AsAsync <ISnapshotsOpenSnapshotResult>(); } long savedTime = result.Snapshot.Metadata.PlayedTime; if (savedTime > lastSave) { //On charge using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutLong("lastSave", savedTime); e.Commit(); } } dataToLoad = result.Snapshot.SnapshotContents.ReadFully(); return(dataToLoad); } else { dataToLoad = null; //On sauve ISnapshotMetadataChange change = new SnapshotMetadataChangeBuilder() .SetDescription("KillTeamManager") .SetPlayedTimeMillis(DateTime.Now.Ticks) .Build(); using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutLong("lastSave", change.PlayedTimeMillis.LongValue()); e.Commit(); } } result.Snapshot.SnapshotContents.WriteBytes(dataToSave); await GamesClass.Snapshots.CommitAndClose(client, result.Snapshot, change); } } } catch (Exception ex) { Crashes.TrackError(ex); } return(null); }
internal NativeSnapshotMetadataChange Build() => NativeSnapshotMetadataChange.FromPointer(SnapshotMetadataChangeBuilder.SnapshotMetadataChange_Builder_Create(base.SelfPtr()));