Exemplo n.º 1
0
 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);
             }
         }
     }));
 }
Exemplo n.º 2
0
        public void Accept(IQuest quest, Action <GooglePlayGames.BasicApi.Quests.QuestAcceptStatus, IQuest> callback)
        {
            Misc.CheckNotNull <IQuest>(quest);
            Misc.CheckNotNull <Action <GooglePlayGames.BasicApi.Quests.QuestAcceptStatus, IQuest> >(callback);
            callback = CallbackUtils.ToOnGameThread <GooglePlayGames.BasicApi.Quests.QuestAcceptStatus, IQuest>(callback);
            NativeQuest quest1 = quest as NativeQuest;

            if (quest1 == null)
            {
                Logger.e("Encountered quest that was not generated by this IQuestClient");
                callback(GooglePlayGames.BasicApi.Quests.QuestAcceptStatus.BadInput, (IQuest)null);
            }
            else
            {
                this.mManager.Accept(quest1, (Action <GooglePlayGames.Native.PInvoke.QuestManager.AcceptResponse>)(response =>
                {
                    if (response.RequestSucceeded())
                    {
                        callback(GooglePlayGames.BasicApi.Quests.QuestAcceptStatus.Success, (IQuest)response.AcceptedQuest());
                    }
                    else
                    {
                        callback(NativeQuestClient.FromAcceptStatus(response.ResponseStatus()), (IQuest)null);
                    }
                }));
            }
        }
Exemplo n.º 3
0
        public void Accept(IQuest quest, Action <QuestAcceptStatus, IQuest> callback)
        {
            Misc.CheckNotNull(quest);
            Misc.CheckNotNull(callback);
            callback = CallbackUtils.ToOnGameThread(callback);
            NativeQuest nativeQuest = quest as NativeQuest;

            if (nativeQuest == null)
            {
                Logger.e("Encountered quest that was not generated by this IQuestClient");
                callback(QuestAcceptStatus.BadInput, null);
            }
            else
            {
                mManager.Accept(nativeQuest, delegate(GooglePlayGames.Native.PInvoke.QuestManager.AcceptResponse response)
                {
                    if (response.RequestSucceeded())
                    {
                        callback(QuestAcceptStatus.Success, response.AcceptedQuest());
                    }
                    else
                    {
                        callback(FromAcceptStatus(response.ResponseStatus()), null);
                    }
                });
            }
        }
Exemplo n.º 4
0
        public void ShowSpecificQuestUI(IQuest quest, Action <QuestUiResult, IQuest, IQuestMilestone> callback)
        {
            Misc.CheckNotNull <IQuest>(quest);
            Misc.CheckNotNull <Action <QuestUiResult, IQuest, IQuestMilestone> >(callback);
            callback = CallbackUtils.ToOnGameThread <QuestUiResult, IQuest, IQuestMilestone>(callback);
            NativeQuest quest1 = quest as NativeQuest;

            if (quest1 == null)
            {
                Logger.e("Encountered quest that was not generated by this IQuestClient");
                callback(QuestUiResult.BadInput, (IQuest)null, (IQuestMilestone)null);
            }
            else
            {
                this.mManager.ShowQuestUI(quest1, NativeQuestClient.FromQuestUICallback(callback));
            }
        }