Ejemplo n.º 1
0
 private void Start()
 {
     //Add starting items
     if (!string.IsNullOrEmpty(unique_id.unique_id))
     {
         bool has_inventory = InventoryData.Exists(unique_id.unique_id);
         if (!has_inventory)
         {
             InventoryData invdata = InventoryData.Get(InventoryType.Storage, unique_id.unique_id);
             foreach (ItemDataValue item in starting_items_quantity)
             {
                 if (item.item != null)
                 {
                     invdata.AddItem(item.item.id, item.quantity, item.item.durability, UniqueID.GenerateUniqueID());
                 }
             }
             foreach (ItemData item in starting_items)
             {
                 if (item != null)
                 {
                     invdata.AddItem(item.id, 1, item.durability, UniqueID.GenerateUniqueID());
                 }
             }
             foreach (CraftDataRandom item in starting_items_random)
             {
                 if (item.item != null && Random.value < item.probability)
                 {
                     ItemData idata = (ItemData)item.item;
                     invdata.AddItem(idata.id, 1, idata.durability, UniqueID.GenerateUniqueID());
                 }
             }
         }
     }
 }
        public void SetInventory(InventoryType type, string uid, int size)
        {
            inventory_type = type;
            inventory_uid  = uid;
            inventory_size = size;

            InventoryData idata = InventoryData.Get(type, uid);

            if (idata != null)
            {
                idata.size = size;
            }
        }
Ejemplo n.º 3
0
        public void DropStorage()
        {
            //Drop storage items
            InventoryData sdata = InventoryData.Get(InventoryType.Storage, GetUID());

            if (sdata != null)
            {
                foreach (KeyValuePair <int, InventoryItemData> item in sdata.items)
                {
                    ItemData idata = ItemData.Get(item.Value.item_id);
                    if (idata != null && item.Value.quantity > 0)
                    {
                        Item.Create(idata, GetLootRandomPos(), item.Value.quantity, item.Value.durability, item.Value.uid);
                    }
                }
            }
        }
        private void Start()
        {
            bool has_inventory = PlayerData.Get().HasInventory(character.player_id);

            InventoryData.size = inventory_size; //This will also create the inventory
            EquipData.size     = 99;             //Create the inventory, size doesnt matter for equip

            //If new game, add starting items
            if (!has_inventory)
            {
                InventoryData invdata = InventoryData.Get(InventoryType.Inventory, character.player_id);
                foreach (ItemData item in starting_items)
                {
                    invdata.AddItem(item.id, 1, item.durability, UniqueID.GenerateUniqueID());
                }
            }
        }
 public InventoryData GetInventory()
 {
     return(InventoryData.Get(inventory_type, inventory_uid));
 }