private static Action <GooglePlayGames.Native.PInvoke.QuestManager.QuestUIResponse> FromQuestUICallback(Action <QuestUiResult, IQuest, IQuestMilestone> callback) { return((Action <GooglePlayGames.Native.PInvoke.QuestManager.QuestUIResponse>)(response => { if (!response.RequestSucceeded()) { callback(NativeQuestClient.UiErrorToQuestUiResult(response.RequestStatus()), (IQuest)null, (IQuestMilestone)null); } else { NativeQuest nativeQuest = response.AcceptedQuest(); NativeQuestMilestone claim = response.MilestoneToClaim(); if (nativeQuest != null) { callback(QuestUiResult.UserRequestsQuestAcceptance, (IQuest)nativeQuest, (IQuestMilestone)null); claim.Dispose(); } else if (claim != null) { callback(QuestUiResult.UserRequestsMilestoneClaiming, (IQuest)null, (IQuestMilestone)response.MilestoneToClaim()); nativeQuest.Dispose(); } else { Logger.e("Quest UI succeeded without a quest acceptance or milestone claim."); nativeQuest.Dispose(); claim.Dispose(); callback(QuestUiResult.InternalError, (IQuest)null, (IQuestMilestone)null); } } })); }
public void ClaimMilestone(IQuestMilestone milestone, Action <GooglePlayGames.BasicApi.Quests.QuestClaimMilestoneStatus, IQuest, IQuestMilestone> callback) { Misc.CheckNotNull <IQuestMilestone>(milestone); Misc.CheckNotNull <Action <GooglePlayGames.BasicApi.Quests.QuestClaimMilestoneStatus, IQuest, IQuestMilestone> >(callback); callback = CallbackUtils.ToOnGameThread <GooglePlayGames.BasicApi.Quests.QuestClaimMilestoneStatus, IQuest, IQuestMilestone>(callback); NativeQuestMilestone milestone1 = milestone as NativeQuestMilestone; if (milestone1 == null) { Logger.e("Encountered milestone that was not generated by this IQuestClient"); callback(GooglePlayGames.BasicApi.Quests.QuestClaimMilestoneStatus.BadInput, (IQuest)null, (IQuestMilestone)null); } else { this.mManager.ClaimMilestone(milestone1, (Action <GooglePlayGames.Native.PInvoke.QuestManager.ClaimMilestoneResponse>)(response => { if (response.RequestSucceeded()) { callback(GooglePlayGames.BasicApi.Quests.QuestClaimMilestoneStatus.Success, (IQuest)response.Quest(), (IQuestMilestone)response.ClaimedMilestone()); } else { callback(NativeQuestClient.FromClaimStatus(response.ResponseStatus()), (IQuest)null, (IQuestMilestone)null); } })); } }
public void ClaimMilestone(IQuestMilestone milestone, Action <QuestClaimMilestoneStatus, IQuest, IQuestMilestone> callback) { Misc.CheckNotNull(milestone); Misc.CheckNotNull(callback); callback = CallbackUtils.ToOnGameThread(callback); NativeQuestMilestone nativeQuestMilestone = milestone as NativeQuestMilestone; if (nativeQuestMilestone == null) { Logger.e("Encountered milestone that was not generated by this IQuestClient"); callback(QuestClaimMilestoneStatus.BadInput, null, null); } else { mManager.ClaimMilestone(nativeQuestMilestone, delegate(GooglePlayGames.Native.PInvoke.QuestManager.ClaimMilestoneResponse response) { if (response.RequestSucceeded()) { callback(QuestClaimMilestoneStatus.Success, response.Quest(), response.ClaimedMilestone()); } else { callback(FromClaimStatus(response.ResponseStatus()), null, null); } }); } }