コード例 #1
0
    public static void LinkFaceBookToPlayFab()
    {
        DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.LinkFacebookId);
        var request = new LinkFacebookAccountRequest {
            AccessToken = AccessToken.CurrentAccessToken.TokenString
        };

        PlayFabClientAPI.LinkFacebookAccount(request, OnLinkSuccess, error =>
        {
            if (!error.ErrorMessage.Contains("already linked")) // ew, gotta get better error codes
            {
                PF_Bridge.RaiseCallbackError(error.ErrorMessage, PlayFabAPIMethods.LinkFacebookId, MessageDisplayStyle.error);
                return;
            }

            PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.LinkFacebookId, MessageDisplayStyle.none);
            Action <bool> afterConfirm = (bool response) =>
            {
                if (!response)
                {
                    return;
                }

                DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.LinkFacebookId);
                request.ForceLink = true;
                PlayFabClientAPI.LinkFacebookAccount(request, OnLinkSuccess, PF_Bridge.PlayFabErrorCallback);
            };

            DialogCanvasController.RequestConfirmationPrompt("Caution!", "Your current facebook account is already linked to another Unicorn Battle player. Do you want to force-bind your Facebook account to this player?", afterConfirm);
        });
    }
コード例 #2
0
    public void ToggleShowOnLogin()
    {
        Action <bool> processResponse = (bool response) => {
            if (response == true)
            {
                this.isShownOnLogin    = !this.isShownOnLogin;
                this.changedLoginState = true;

                if (this.isShownOnLogin)
                {
                    this.showOnLogin.GetComponent <Image> ().overrideSprite = this.checkedBox;
                }
                else
                {
                    this.showOnLogin.GetComponent <Image> ().overrideSprite = this.uncheckedBox;
                }
            }
        };

        if (this.isShownOnLogin == true)
        {
            DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.TOGGLE_PROMPT, GlobalStrings.TOGGLE_MSG, processResponse);
        }
        else
        {
            processResponse.Invoke(true);
        }
    }
コード例 #3
0
    public void ToggleFacebookLink()
    {
        if (FB.IsLoggedIn)
        {
            Action <bool> afterCheck = response =>
            {
                if (response)
                {
                    PF_Authentication.UnlinkFbAccount();
                }
            };

            if (!PF_PlayerData.isPlayFabRegistered)
            {
                DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.CONFIRM_UNLINK_PROMPT, GlobalStrings.CONFIRM_UNLINK_MSG, afterCheck);
            }
            else
            {
                DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.CONFIRM_UNLINK_PROMPT, "Are you sure?", afterCheck);
            }
        }
        else
        {
            PF_Authentication.StartFacebookLogin(); // This will do the linking automatically based on being logged in
        }
    }
コード例 #4
0
    public void DeleteCharacter()
    {
        Action <bool> processResponse = (bool response) => {
            if (response == true && this.selectedSlot != null)
            {
                PF_PlayerData.DeleteCharacter(this.selectedSlot.saved.characterDetails.CharacterId);
                this.selectedSlot = null;
            }
        };

        DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.DEL_CHAR_PROMPT, string.Format(GlobalStrings.DEL_CHAR_MSG, this.selectedSlot.ponyName.text), processResponse);
    }
コード例 #5
0
    public void SendRecoveryEmail()
    {
        Action <bool> afterCheck = (bool response) =>
        {
            if (response == true)
            {
                var email = string.IsNullOrEmpty(PF_PlayerData.accountInfo.PrivateInfo.Email) || PF_PlayerData.accountInfo.PrivateInfo.Email.Contains("Pending Refresh") ? this.rc.email.text : PF_PlayerData.accountInfo.PrivateInfo.Email;
                PF_Authentication.SendAccountRecoveryEmail(email);
            }
        };

        DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.RECOVER_EMAIL_PROMPT, GlobalStrings.RECOVER_EMAIL_MSG, afterCheck);
    }
コード例 #6
0
    public void Logout()
    {
        Action <bool> processResponse = (bool response) => {
            if (response == true)
            {
                PF_PlayerData.activeCharacter = null;
                CloseSettingsMenu();
                PF_Authentication.Logout();
            }
        };

        DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.LOGOUT_PROMPT, GlobalStrings.LOGOUT_MSG, processResponse);
    }
コード例 #7
0
    public void ToggleFacebookLink()
    {
        if (PF_PlayerData.accountInfo.FacebookInfo != null)
        {
            Action <bool> afterCheck = (bool response) =>
            {
                if (response == true)
                {
                    //unlink
                    UnityAction afterUnlink = () =>
                    {
                        Text txt = this.linkToFaceBook.GetComponentInChildren <Text>();
                        txt.color = Color.red;
                        txt.text  = GlobalStrings.LINK_FB_BTN_MSG;
                        this.facebookPicture.overrideSprite = null;
                        Debug.Log("NEED ACCOUNT REFRESH???");
                        PF_PlayerData.accountInfo.FacebookInfo = null;
                        this.changedLoginState = true;
                    };

                    PF_PlayerData.UnlinkFBAccount(afterUnlink);
                }
            };

            DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.CONFIRM_UNLINK_PROMPT, GlobalStrings.CONFIRM_UNLINK_MSG, afterCheck);
        }
        else
        {
            // link
            UnityAction afterLink = () =>
            {
                Text btnText = this.linkToFaceBook.GetComponentInChildren <Text>();
                btnText.text  = GlobalStrings.UNLINK_FB_BTN_MSG;
                btnText.color = Color.green;


                Debug.Log("NEED ACCOUNT REFRESH???");
                this.changedLoginState = true;
                PF_PlayerData.accountInfo.FacebookInfo = new UserFacebookInfo();

                UnityAction <Texture2D> afterGetPhoto = (Texture2D tx) =>
                {
                    facebookPicture.overrideSprite = Sprite.Create(tx, new Rect(0, 0, 128, 128), new Vector2());
                };

                StartCoroutine(FacebookHelperClass.GetPlayerProfilePhoto(FetchWebAsset, afterGetPhoto));
            };

            PF_PlayerData.LinkFBAccount(afterLink);
        }
    }
コード例 #8
0
    public void LeaveBattle()
    {
        Action <bool> processResponse = (bool response) => {
            if (response == true)
            {
                Dictionary <string, object> eventData = new Dictionary <string, object>()
                {
                    { "Current_Quest", PF_GamePlay.ActiveQuest.levelName },
                    { "Character_ID", PF_PlayerData.activeCharacter.characterDetails.CharacterId }
                };
                PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_BattleAborted, eventData);

                CloseSettingsMenu();
                SceneController.Instance.RequestSceneChange(SceneController.GameScenes.Profile, .333f);
            }
        };

        DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.QUIT_LEVEL_PROMPT, GlobalStrings.QUIT_LEVEL_MSG, processResponse);
    }
コード例 #9
0
    public void ToggleShowOnLogin()
    {
        Action <bool> processResponse = response =>
        {
            if (!response)
            {
                return;
            }

            PF_PlayerData.showAccountOptionsOnLogin = !PF_PlayerData.showAccountOptionsOnLogin;
            changedLoginState = true;
            SetCheckBox(showOnLogin.GetComponent <Image>(), PF_PlayerData.showAccountOptionsOnLogin);
        };

        if (PF_PlayerData.showAccountOptionsOnLogin)
        {
            DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.TOGGLE_PROMPT, GlobalStrings.TOGGLE_MSG, processResponse);
        }
        else
        {
            processResponse.Invoke(true);
        }
    }
コード例 #10
0
    public void TogglePushNotification()
    {
        if (!PF_PlayerData.isRegisteredForPush)
        {
            DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.Generic);
            UnityAction afterPush = () =>
            {
                changedLoginState = true;
                PF_PlayerData.isRegisteredForPush = true;
                SetCheckBox(registerPush.GetComponent <Image>(), true);
                Debug.Log("AccountStatusController: PUSH ENABLED!");
                PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.Generic, MessageDisplayStyle.none);
            };

            StartCoroutine(PF_GamePlay.Wait(1.5f, () =>
            {
                PF_PlayerData.RegisterForPushNotification(pushToken, afterPush);
            }));
        }
        else
        {
            Action <bool> processResponse = response =>
            {
                if (!response)
                {
                    return;
                }

                changedLoginState = true;
                PF_PlayerData.isRegisteredForPush = false;
                SetCheckBox(registerPush.GetComponent <Image>(), false);
                Debug.Log("AccountStatusController: PUSH DISABLED!");
            };

            DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.PUSH_NOTIFY_PROMPT, GlobalStrings.PUSH_NOTIFY_MSG, processResponse);
        }
    }
コード例 #11
0
    private void Update()
    {
        if (msgToProcess != null)
        {
            if (!(msgToProcess.showStore) && (msgToProcess.message != null))
            {
                DialogCanvasController.RequestStatusPrompt(msgToProcess.title, msgToProcess.message, () => {});
            }

            if ((msgToProcess.showStore) && (msgToProcess.message != null))
            {
                DialogCanvasController.RequestConfirmationPrompt(msgToProcess.title, msgToProcess.message,
                                                                 (response) =>
                {
                    if (response)
                    {
                        DialogCanvasController.RequestStore(PF_GameData.StandardStores[0]);
                    }
                }
                                                                 );
            }
        }
        msgToProcess = null;
    }
コード例 #12
0
    public static void OnReportAdActivitySuccess(RewardAdActivityResponse result)
    {
        Debug.Log("OnReportAdActivitySuccess!");
        Debug.Log(string.Format("Retrieved {0} items and {1} VCs.", result.RewardResults.GrantedItems.Count, result.RewardResults.GrantedVirtualCurrencies.Count));

        var gotItems = false;
        var gotVc    = false;

        var           output    = "Congratulations! ";
        List <string> itemGifts = new List <string>();

        if (result.RewardResults.GrantedItems != null && result.RewardResults.GrantedItems.Count > 0)
        {
            gotItems = true;
            output  += "You received: " + result.RewardResults.GrantedItems.Count + " new items";

            foreach (var item in result.RewardResults.GrantedItems)
            {
                itemGifts.Add(item.ItemId);
            }
        }

        if (result.RewardResults.GrantedVirtualCurrencies != null && result.RewardResults.GrantedVirtualCurrencies.Count > 0)
        {
            gotVc = true;

            var count = 0;
            foreach (var grant in result.RewardResults.GrantedVirtualCurrencies)
            {
                if (gotItems || count > 0)
                {
                    output += "; ";
                }
                else
                {
                    output += "You received: ";
                }

                output += string.Format("{1}({0})", grant.Key, grant.Value);

                count++;
            }

            output += " in Virtual Currencies";
        }

        if (result.RewardResults.IncrementedStatistics != null && result.RewardResults.IncrementedStatistics.Count > 0)
        {
            var count = 0;
            foreach (var stat in result.RewardResults.IncrementedStatistics)
            {
                if (gotItems || gotVc || count > 0)
                {
                    output += "; ";
                }

                output += string.Format(" Your \"{0}\" increased by {1}", stat.Key, stat.Value);

                count++;
            }
        }

        if (gotItems)
        {
            output += ".\n Click the check mark to view your new items.";
        }

        if (OnAdRewarded != null)
        {
            OnAdRewarded(result);
        }

        DialogCanvasController.RequestConfirmationPrompt("You were granted a gift!", output, response =>
        {
            if (response && gotItems)
            {
                DialogCanvasController.RequestItemViewer(itemGifts);
            }
        });
    }