コード例 #1
0
    public void TargetReciveItem(NetworkConnection target, string itemid, int numtag, int num)
    {
        ItemData item = UnitZ.itemManager.GetItemDataByID(itemid);

        if (inventory != null && item != null)
        {
            if (inventory.AddItemTest(item, num))
            {
                if (inventory.stickerTarget != null)
                {
                    if (!inventory.DropItemBySticker(inventory.stickerTarget))
                    {
                        //Debug.Log("stick is empty");
                        inventory.DropItemBySameEquipType(item);
                    }
                    ItemCollector lastItemPicked = inventory.AddItemByItemData(item, num, numtag, inventory.stickerTarget.Index);
                    if (lastItemPicked != null)
                    {
                        //Debug.Log("Equip from ground " + lastItemPicked.Item.ItemName);
                        inventory.EquipItemToStickerByCollector(lastItemPicked, inventory.stickerTarget);
                        inventory.OnViewChanged();
                    }
                    inventory.stickerTarget = null;
                }
                else
                {
                    inventory.DropItemBySameEquipType(item);
                    ItemCollector lastItemPicked = inventory.AddItemByItemData(item, num, numtag, -1);
                }

                if (item.SoundPickup)
                {
                    AudioSource.PlayClipAtPoint(item.SoundPickup, this.transform.position);
                }
            }
        }
    }