コード例 #1
0
    public void TransferItem()
    {
        if (this.selectedItem.itemData.category.itemId == "ExtraCharacterSlot")
        {
            return;
        }

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

        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);
            }
        }

        UnityAction <int> afterSelect = (int response) =>
        {
            var item = this.selectedItem.itemData.category.inventory.FirstOrDefault();

            if (this.activeMode == InventoryMode.Character && response == 0) // stand alone
            {
                // send this to the player account
                Debug.Log("Moved " + item.DisplayName + " to Player");

                PF_PlayerData.TransferItemToPlayer(PF_PlayerData.activeCharacter.characterDetails.CharacterId, item.ItemInstanceId, 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";
                }

                // send this to another character
                if (item != null)
                {
                    Debug.Log("Moved " + item.DisplayName + " to Character: " + transOptions[response] + " -- " + PF_PlayerData.playerCharacters[response].CharacterId);
                    PF_PlayerData.TransferItemToCharacter(PF_PlayerData.activeCharacter.characterDetails.CharacterId, sourceType, item.ItemInstanceId, PF_PlayerData.playerCharacters[response].CharacterId, RefreshInventory);
                }
            }
        };

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