/// <summary>
    /// Links a mobile device to a PlayFab account via the unique device id (A device can only be linked to one account at a time)
    /// </summary>
    public static void LinkDeviceId()
    {
        if (!GetDeviceId())
        {
            return;
        }

        UnityAction <PlayFabError> onLinkError = error =>
        {
            PF_Bridge.RaiseCallbackError("Unable to link device: " + error.ErrorMessage, PlayFabAPIMethods.LinkDeviceID, MessageDisplayStyle.error);
        };

        if (!string.IsNullOrEmpty(android_id))
        {
            Debug.Log("Linking Android");
            var request = new LinkAndroidDeviceIDRequest {
                AndroidDeviceId = android_id
            };

            PlayFabClientAPI.LinkAndroidDeviceID(request, null, error => { onLinkError(error); });
        }
        else if (!string.IsNullOrEmpty(ios_id))
        {
            Debug.Log("Linking iOS");
            var request = new LinkIOSDeviceIDRequest {
                DeviceId = ios_id
            };

            PlayFabClientAPI.LinkIOSDeviceID(request, null, error => { onLinkError(error); });
        }
    }
Exemple #2
0
    public void OnCharacterClicked(CharacterDisplayItem cha)
    {
        selectedCharacter = cha;

        if (chaDetail != null && !teamController.isChangingMember)
        {
            chaDetail.Init(cha);
        }
        else if (teamController.isChangingMember)
        {
            if (CheckIsSameCharacterInTeam(cha.saved.baseClass.CatalogCode))
            {
                Debug.LogError("same character is in team already");
                PF_Bridge.RaiseCallbackError("same character is in the team already", PlayFabAPIMethods.Generic, MessageDisplayStyle.context);
                teamController.Refresh();
                return;
            }

            if (string.IsNullOrEmpty(selectedMember.myId.text))
            {
                PF_PlayerData.MyTeamsCharacterId["CurrentTeam"].Add(cha.saved.characterDetails.CharacterId);
            }
            else
            {
                int index = PF_PlayerData.MyTeamsCharacterId["CurrentTeam"].FindIndex(x => x.Contains(selectedMember.myId.text));
                PF_PlayerData.MyTeamsCharacterId["CurrentTeam"][index] = cha.saved.characterDetails.CharacterId;
            }
            UpdateTeam();
            teamController.Refresh();
        }
    }
Exemple #3
0
    private IEnumerator OutgoingApiTimeoutCallback()
    {
        while (this.waitingOnRequests.Count > 0)
        {
            for (var z = 0; z < this.waitingOnRequests.Count; z++)
            {
                if (Time.time > (this.waitingOnRequests[z].outgoingGameTime + this.timeOutLength))
                {
                    // time has elapsed for this request, until we can handle this more specifically, we can only reload the scene, and hope for the best.
                    PlayFabAPIMethods capturedDetails = this.waitingOnRequests[z].method;
                    PF_Bridge.RaiseCallbackError(string.Format("API Call: {0} Timed out after {1} seconds.", capturedDetails, this.timeOutLength), this.waitingOnRequests[z].method, MessageDisplayStyle.error);

                    Action <bool> afterConfirmation = (bool response) => {
                        if (response == false)
                        {
                            // user clicked cancel (to reload);
                            Debug.LogErrorFormat("Reloading scene due {0} API timing out.", capturedDetails);
                            SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
                        }
                    };
                    //modifing
                    //DialogCanvasController.RequestConfirmationPrompt("Caution! Bravery Required!", string.Format("API Call: {0} Timed out. \n\tACCEPT: To proceed, may cause client instability. \n\tCANCEL: To reload this scene and hope for the best.", capturedDetails), afterConfirmation);
                }
            }

            // tick once per second while we have outbound requests. (keep enabled while debugging this feature)
            Debug.Log(string.Format("{0}", (int)Time.time % 2 == 0 ? "Tick" : "Tock"));
            yield return(new WaitForSeconds(1f));
        }

        // outgoing request queue empty
        this.timeOutCallback = null;
        yield break;
    }
    public IEnumerator GetDownloadEndpoints(List <AssetBundleHelperObject> assets, UnityAction <bool> callback = null)
    {
        float stTime  = Time.time;
        float timeOut = 30;

        foreach (var asset in assets)
        {
            //StartCoroutine(DownloadAndUnpackAsset(asset));
            Debug.Log("Requesting url for GET: " + asset.FileName);
            GetContentDownloadURL(asset);
        }

        while (DoAllAssetsHaveDownloadEndpoints(assets) == false)
        {
            if (Time.time > stTime + timeOut)
            {
                Debug.Log("Error: TimeOut");
                PF_Bridge.RaiseCallbackError("CDN Timeout: Could not obtain endpoints", PlayFabAPIMethods.GetCDNConent, MessageDisplayStyle.error);
                yield break;
            }
            yield return(0);
        }

        Debug.Log("--- DownloadEndpoint Complete ---");
        StartCoroutine(GetAssetPackages(this.assets, callback));
        yield break;
    }
    void SigninWithFB(bool testMode = false)
    {
        UnityAction afterFBInit = () =>
        {
            FB.ActivateApp();
            FB.LogInWithReadPermissions(new List <string>()
            {
                "public_profile", "email", "user_friends"
            }, (ILoginResult response) =>
            {
                if (response.Error != null)
                {
                    PF_Bridge.RaiseCallbackError("Facebook Error: " + response.Error, PlayFabAPIMethods.LoginWithFacebook, MessageDisplayStyle.none);
                }
                else if (!FB.IsLoggedIn)
                {
                    PF_Bridge.RaiseCallbackError("You canceled the Facebook session, without an active facebook session photos and other data will not be accessable.", PlayFabAPIMethods.LoginWithFacebook, MessageDisplayStyle.none);
                }
                else
                {
                    PF_Authentication.usedManualFacebook = testMode == true ? false : true;
                    PF_Authentication.LoginWithFacebook(AccessToken.CurrentAccessToken.TokenString, true);
                }
            });
        };

        PF_Authentication.StartFacebookLogin(() =>
        {
            afterFBInit();
        });
    }
    private static void FacebookLoginCallback(ILoginResult result)
    {
        var fbAction = PlayFabClientAPI.IsClientLoggedIn() ? PlayFabAPIMethods.LinkFacebookId : PlayFabAPIMethods.LoginWithFacebook;

        if (result.Error != null)
        {
            PF_Bridge.RaiseCallbackError("Facebook Error: " + result.Error, fbAction, MessageDisplayStyle.none);
            return;
        }
        else if (!FB.IsLoggedIn)
        {
            PF_Bridge.RaiseCallbackError("Facebook Error: Login cancelled by Player", fbAction, MessageDisplayStyle.none);
            return;
        }

        // PlayFab Facebook Login
        if (fbAction == PlayFabAPIMethods.LinkFacebookId)
        {
            LinkFaceBookToPlayFab();
        }
        else
        {
            PlayFabLoginWithFacebook(AccessToken.CurrentAccessToken.TokenString, true);
        }
    }
    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);
        });
    }
Exemple #8
0
    public void OpenCommunityPortal()
    {
        if (string.IsNullOrEmpty(PF_GameData.CommunityWebsite))
        {
            PF_Bridge.RaiseCallbackError("No URL was found for the Community Portal. Check TitleData.", PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
            return;
        }

        Application.OpenURL(PF_GameData.CommunityWebsite);
    }
Exemple #9
0
 public void WatchAd()
 {
     if (activePromo != null && activePromo.linkedAd != null && SupersonicEvents.rewardedVideoAvailability && Time.time > _watchLastClickedAt + _watchCD)
     {
         _watchLastClickedAt = Time.time;
         SupersonicEvents.ShowRewardedVideo(activePromo.linkedAd.Details);
     }
     else
     {
         PF_Bridge.RaiseCallbackError("Rewarded ad is unavailable at this time. Please try again later.", PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
     }
 }
Exemple #10
0
 /// <summary>
 /// Makes the RM purchase.
 /// </summary>
 /// <param name="itemId">Item identifier.</param>
 public static void MakeRmPurchase(string itemId)
 {
     if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
     {
         DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.MakePurchase);
         OnePF.OpenIAB.purchaseProduct(itemId);
     }
     else
     {
         PF_Bridge.RaiseCallbackError("Current plaform does not support IAP; cannot process transaction.", PlayFabAPIMethods.MakePurchase, MessageDisplayStyle.error);
     }
 }
Exemple #11
0
 public void RegisterClicked()
 {
     if (!string.IsNullOrEmpty(pass1.text) && !string.IsNullOrEmpty(pass2.text) && string.Equals(pass1.text, pass2.text))
     {
         PF_Authentication.AddUserNameAndPassword(userName.text, pass1.text, email.text, result =>
         {
             callback(result);
             CloseRegistration();
         });
     }
     else
     {
         PF_Bridge.RaiseCallbackError(GlobalStrings.REGISTER_FAIL_MSG, PlayFabAPIMethods.AddUsernamePassword, MessageDisplayStyle.error);
     }
 }
    public void CheckForPlayFabPlacement(string placement = null)
    {
        Action <PlayFabError> errorCb = error =>
        {
            if (error.GenerateErrorReport().Contains("AllAdPlacementViewsAlreadyConsumed"))
            {
                //PF_Bridge.RaiseCallbackError(string.Format("No more rewared ads can be viewed at this time. Check back in {0} minutes",  ), PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
                var adpromo = promos.Find((p) => { return(p.linkedAd != null); });

                if (adpromo != null)
                {
                    Debug.Log(string.IsNullOrEmpty(adpromo.assets.PromoId) ? "AdPromo was not null... removing: " + adpromo.assets.PromoId : "Unknown");
                    promos.Remove(adpromo);
                    SetAdSlotCount(promos.Count);
                    SelectBanner();
                    Debug.Log("Promo Count: " + promos.Count);
                }
                else
                {
                    Debug.Log("AdPromo not in rotation.");
                }
            }
            else
            {
                PF_Bridge.RaiseCallbackError(error.GenerateErrorReport(), PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
            }
        };

        // SupersonicEvents.queuedAd = null;

        if (placement != null)
        {
            // PF_Advertising.GetAdPlacements(new GetAdPlacementsRequest { Identifier = new NameIdentifier() { Name = placement }, AppId = SupersonicEvents.appKey }, OnCheckForPlayFabPlacementSuccess, errorCb);
            PF_Advertising.GetAdPlacements(new GetAdPlacementsRequest {
                Identifier = new NameIdentifier()
                {
                    Name = placement
                }, AppId = "0"
            }, OnCheckForPlayFabPlacementSuccess, errorCb);
        }
        else
        {
            // PF_Advertising.GetAdPlacements(new GetAdPlacementsRequest { AppId = SupersonicEvents.appKey }, OnCheckForPlayFabPlacementSuccess, errorCb);
            PF_Advertising.GetAdPlacements(new GetAdPlacementsRequest {
                AppId = "0"
            }, OnCheckForPlayFabPlacementSuccess, errorCb);
        }
    }
Exemple #13
0
    public static void OnCreateNewCharacterSuccess(ExecuteCloudScriptResult result)
    {
        if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
        {
            return;
        }

        if ((bool)result.FunctionResult)
        {
            PF_Bridge.RaiseCallbackSuccess("New Character Added", PlayFabAPIMethods.GrantCharacterToUser, MessageDisplayStyle.none);
        }
        else
        {
            PF_Bridge.RaiseCallbackError("Error Creating Character" + result.Logs.ToString(), PlayFabAPIMethods.GrantCharacterToUser, MessageDisplayStyle.error);
        }
    }
Exemple #14
0
    private static void OnDeleteCharacterSuccess(ExecuteCloudScriptResult result)
    {
        if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
        {
            return;
        }

        if ((bool)result.FunctionResult)
        {
            PF_Bridge.RaiseCallbackSuccess("Character Deleted", PlayFabAPIMethods.DeleteCharacter, MessageDisplayStyle.none);
        }
        else
        {
            PF_Bridge.RaiseCallbackError("Error Deleting Character" + result.Logs.ToString(), PlayFabAPIMethods.DeleteCharacter, MessageDisplayStyle.none);
        }
    }
Exemple #15
0
    // move to PF_PlayerData?
    public void ShowItemOffer(ItemInstance item)
    {
        this.activeItem     = PF_GameData.offersCataogItems.Find((i) => { return(i.ItemId == item.ItemId); });
        this.activeInstance = item;

        if (activeItem != null)
        {
            if (activeItem.Tags.IndexOf("SingleUse") > -1)
            {
                if (PF_PlayerData.RedeemedOffers.IndexOf(activeItem.ItemId) > -1)
                {
                    // this is a onetime offer and it has already been redeemed for this player.
                    PF_Bridge.RaiseCallbackError("This is a one-time offer and it has already redeemed for this player.", PlayFabAPIMethods.ConsumeOffer, MessageDisplayStyle.error);
                    ContinueClicked(true);
                    return;
                }
            }

            this.OfferName.text = activeItem.DisplayName;
            this.OfferDesc.text = activeItem.Description;

            Dictionary <string, string> customData = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(activeItem.CustomData);

            string itemAwarded = "Random DropTable";
            customData.TryGetValue("itemAwarded", out itemAwarded);


            string awardIcon = "Default";
            if (customData.ContainsKey("itemAwarded"))
            {
                CatalogItem awardItem = PF_GameData.catalogItems.Find((i) => { return(i.ItemId == itemAwarded); });
                Dictionary <string, string> awardCustomData = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(awardItem.CustomData);

                awardCustomData.TryGetValue("icon", out awardIcon);
                this.ItemName.text = awardItem.DisplayName;
            }
            else
            {
                this.ItemName.text = "Offer reward not found.";
            }
            this.ItemIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(awardIcon);
            this.OfferItem.gameObject.SetActive(true);

            this.OfferStore.gameObject.SetActive(false);
        }
    }
Exemple #16
0
    /// <summary>
    /// Starts the buy store item.
    /// </summary>
    /// <param name="item">Item.</param>
    /// <param name="storeID">Store I.</param>
    public static void StartBuyStoreItem(CatalogItem item, string storeID)
    {
        string characterId = null;//PF_PlayerData.activeCharacter == null ? null : PF_PlayerData.activeCharacter.characterDetails.CharacterId;
        var    vcKVP       = item.VirtualCurrencyPrices.First();

        if (characterId != null)
        {
            DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.MakePurchase);

            ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest();
            request.FunctionName = "PurchaseItem";
            //request.FunctionParameter = new { ItemPrice = (int)vcKVP.Value, CurrencyCode = vcKVP.Key, CharacterId = PF_PlayerData.activeCharacter.characterDetails.CharacterId, ItemId = item.ItemId };

            PlayFabClientAPI.ExecuteCloudScript(request, (ExecuteCloudScriptResult result) =>
            {
                if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
                {
                    return;
                }

                if ((bool)result.FunctionResult == true)
                {
                    PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.MakePurchase, MessageDisplayStyle.none);
                }
                else
                {
                    PF_Bridge.RaiseCallbackError("Could not process request due to insufficient VC.", PlayFabAPIMethods.MakePurchase, MessageDisplayStyle.error);
                }
            }, PF_Bridge.PlayFabErrorCallback);
        }
        else if (characterId == null)
        {
            // normal purchase item flow
            PurchaseItemRequest request = new PurchaseItemRequest();
            request.ItemId          = item.ItemId;
            request.VirtualCurrency = vcKVP.Key;
            request.Price           = (int)vcKVP.Value;
            request.StoreId         = storeID;
            DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.MakePurchase);
            PlayFabClientAPI.PurchaseItem(request, OnBuyStoreItemSuccess, PF_Bridge.PlayFabErrorCallback);
        }
        else
        {
            Debug.LogWarning("Store purchase failed: " + characterId);
        }
    }
    public IEnumerator GetAssetPackages(List <AssetBundleHelperObject> assets, UnityAction <bool> callback = null)
    {
        float stTime  = Time.time;
        float timeOut = 30;

        foreach (var asset in assets)
        {
            StartCoroutine(DownloadAndUnpackAsset(asset));
        }

        while (AreAssetDownloadsAndUnpacksComplete(assets) == false)
        {
            if (Time.time > stTime + timeOut)
            {
                //Debug.Log ("Error: TimeOut");
                PF_Bridge.RaiseCallbackError("CDN Timeout: Could not obtain AssetBundles", PlayFabAPIMethods.GetCDNConent, MessageDisplayStyle.error);

                if (callback != null)
                {
                    callback(false);
                }

                yield break;
            }

            yield return(0);
        }

        foreach (var asset in assets)
        {
            unpackedAssets.Add(asset.FileName, asset.Unpacked);
        }

        if (callback != null)
        {
            callback(true);
        }
        Debug.Log("--- AllComplete ---");
        yield break;
    }
Exemple #18
0
    public IEnumerator GetDownloadEndpoints(List <AssetBundleHelperObject> assets, UnityAction <bool> callback = null)
    {
        var endTime = Time.time + 30.0f;

        foreach (var asset in assets)
        {
            GetContentDownloadURL(asset);
        }

        while (DoAllAssetsHaveDownloadEndpoints(assets) == false)
        {
            if (Time.time > endTime)
            {
                Debug.Log("Error: TimeOut");
                PF_Bridge.RaiseCallbackError("CDN Timeout: Could not obtain endpoints", PlayFabAPIMethods.GetCDNConent, MessageDisplayStyle.error);
                yield break;
            }
            yield return(0);
        }

        StartCoroutine(GetAssetPackages(assets, callback));
    }
    /// <summary>
    /// Login with Facebook token.
    /// </summary>
    /// <param name="token">Token obtained through the FB plugin. (works on mobile and FB canvas only)</param>
    public static void LoginWithFacebook(string token, bool createAccount = false, UnityAction errCallback = null)
    {
        //LoginMethodUsed = LoginPathways.facebook;
        LoginWithFacebookRequest request = new LoginWithFacebookRequest();

        request.AccessToken   = token;
        request.TitleId       = PlayFabSettings.TitleId;
        request.CreateAccount = createAccount;

        DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin);
        PlayFabClientAPI.LoginWithFacebook(request, OnLoginResult, (PlayFabError error) =>
        {
            if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound)
            {
                errCallback();
                PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.error);
            }
            else
            {
                OnLoginError(error);
            }
        });
    }
    /// <summary>
    /// Logins the with device identifier (iOS & Android only).
    /// </summary>
    public static void LoginWithDeviceId(bool createAcount, UnityAction errCallback)
    {
        Action <bool> processResponse = (bool response) =>
        {
            if (response && GetDeviceId())
            {
                if (!string.IsNullOrEmpty(android_id))
                {
                    Debug.Log("Using Android Device ID: " + android_id);
                    var request = new LoginWithAndroidDeviceIDRequest
                    {
                        AndroidDeviceId = android_id,
                        TitleId         = PlayFabSettings.TitleId,
                        CreateAccount   = createAcount
                    };

                    DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin);
                    PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginResult, (PlayFabError error) =>
                    {
                        if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound)
                        {
                            errCallback();
                            PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none);
                        }
                        else
                        {
                            OnLoginError(error);
                        }
                    });
                }
                else if (!string.IsNullOrEmpty(ios_id))
                {
                    Debug.Log("Using IOS Device ID: " + ios_id);
                    var request = new LoginWithIOSDeviceIDRequest
                    {
                        DeviceId      = ios_id,
                        TitleId       = PlayFabSettings.TitleId,
                        CreateAccount = createAcount
                    };

                    DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin);
                    PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginResult, (PlayFabError error) =>
                    {
                        if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound)
                        {
                            errCallback();
                            PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none);
                        }
                        else
                        {
                            OnLoginError(error);
                        }
                    });
                }
            }
            else
            {
                Debug.Log("Using custom device ID: " + custom_id);
                var request = new LoginWithCustomIDRequest
                {
                    CustomId      = custom_id,
                    TitleId       = PlayFabSettings.TitleId,
                    CreateAccount = createAcount
                };

                DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin);
                PlayFabClientAPI.LoginWithCustomID(request, OnLoginResult, error =>
                {
                    if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound)
                    {
                        errCallback();
                        PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none);
                    }
                    else
                    {
                        OnLoginError(error);
                    }
                });
            }
        };

        processResponse(true);
        //DialogCanvasController.RequestConfirmationPrompt("Login With Device ID", "Logging in with device ID has some issue. Are you sure you want to contine?", processResponse);
    }
 private void OnConsumePurchaseFailed(string error)
 {
     Debug.Log("Consume purchase failed: " + error);
     // _processingPayment = false;
     PF_Bridge.RaiseCallbackError(error, PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
 }
Exemple #22
0
    public void TransferVC()
    {
        // specify Currency Code
        // enter currency amount
        // select recipient

        string cCode  = "";
        int    amount = 0;

        //if player, show picker for valid characters
        //if character, show picker for valid characters + Player
        List <string> transOptions = new List <string>();

        UnityAction <int> afterSelect = (int response) =>
        {
            if (this.activeMode == InventoryMode.Character && response == 0) // stand alone
            {
                // send this to the player account
                Debug.Log("Moved " + amount + cCode + " to Player");
                PF_PlayerData.TransferVcToPlayer(PF_PlayerData.activeCharacter.characterDetails.CharacterId, cCode, amount, RefreshInventory);
            }
            else
            {
                string sourceType = "Player";
                if (this.activeMode == InventoryMode.Character) // stand alone
                {
                    // remove the player option since 0 was not selected
                    transOptions.RemoveAt(0);
                    response--;
                    sourceType = "Character";
                }

                Debug.Log("Moved " + amount + cCode + " to Character: " + transOptions[response] + " -- " + PF_PlayerData.playerCharacters[response].CharacterId);
                PF_PlayerData.TransferVCToCharacter(PF_PlayerData.activeCharacter.characterDetails.CharacterId, sourceType, cCode, amount, PF_PlayerData.playerCharacters[response].CharacterId, RefreshInventory);
            }
        };

        Action <string> afterSetAmount = (string response) =>
        {
            if (string.IsNullOrEmpty(response))
            {
                return;  //user canceled.
            }
            if (!Int32.TryParse(response, out amount) || response == "0")
            {
                PF_Bridge.RaiseCallbackError("Please enter an interger > 0 for VC amount", PlayFabAPIMethods.Generic, MessageDisplayStyle.error);
            }
            else
            {
                if (this.activeMode == InventoryMode.Character)
                {
                    transOptions.Add("Player");
                }

                foreach (var c in PF_PlayerData.playerCharacters)
                {
                    if (this.activeMode == InventoryMode.Character && c.CharacterId == PF_PlayerData.activeCharacter.characterDetails.CharacterId)
                    {
                        //Probably better logic for this, and I should feel sad (but i dont).
                    }
                    else
                    {
                        transOptions.Add(c.CharacterName);
                    }
                }

                DialogCanvasController.RequestSelectorPrompt("Choose a recipient", transOptions, afterSelect);
            }
        };

        UnityAction <int> afterSelectCC = (int response) =>
        {
            cCode = this.currenciesInUse[response];
            DialogCanvasController.RequestTextInputPrompt("Set an amount to transfer:", "Enter the amount that you wish to send.", afterSetAmount, "0");
        };

        DialogCanvasController.RequestSelectorPrompt("Select a VC:", this.currenciesInUse, afterSelectCC);
    }
Exemple #23
0
 private static void OnUpdateUserStatisticsError(PlayFabError error)
 {
     PF_Bridge.RaiseCallbackError(error.ErrorMessage, PlayFabAPIMethods.UpdateUserStatistics, MessageDisplayStyle.error);
 }