Exemple #1
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);
    }