Esempio n. 1
0
    void AddItemToInventory(WorldItem request)
    {
        if (!IsOwner)
        {
            return;
        }
        Item shipped_item = ItemCatalogue.RequestItem(request.item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!IsServer)
            {
                InvokeServerRpc(RPC_AddSharedItemNetwork, request.NetworkId, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                RPC_AddSharedItemNetwork(request.NetworkId, 1);
            }
        }
        else if (AbilityItem.isAbilityItem(shipped_item))
        {
            shipped_item.context   = this;
            shipped_item.menu_form = Resources.Load(shipped_item.name() + "MenuForm") as Sprite;
            actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item;
            actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name());
        }
    }
    void AddItemToInventory(ItemRequest request)
    {
        if (!isOwner)
        {
            return;
        }
        Item shipped_item = amazon.RequestItem(request.item_name);

        if (SharedItem.isSharedItem(shipped_item))
        {
            if (!isServer)
            {
                InvokeServerRpc(RPC_AddSharedItem, request.item_name, 1, channel: INVMANG_CHANNEL);
            }
            else
            {
                string            item_name = request.item_name;
                uint              clientId  = NetworkingManager.singleton.LocalClientId;
                NetworkSharedItem netItem   = new NetworkSharedItem(item_name);
                networkInv.AddItemStack(item_name, netItem, 1);
            }
        }
        if (AbilityItem.isAbilityItem(shipped_item))
        {
            shipped_item.context   = this;
            shipped_item.menu_form = image;
            actionSlots.ability_items[shipped_item.name()] = (AbilityItem)shipped_item;
            actionSlots.ChangeAbilityItem(actionSlots.ability_items.GetStackCount(), shipped_item.name());
        }
        GameObject.Destroy(request.gameObject);
    }