示例#1
0
        public void SaveInventory()
        {
            var data = new ContainerSaveData(slots);

            for (int i = 0; i < data.savedSlots.Length; i++)
            {
                if (items[i] != null)
                {
                    if (items[i].item == null)
                    {
                        data.savedSlots[i] = null;
                    }
                    else
                    {
                        data.savedSlots[i] = new ItemSaveData(items[i].item, items[i].amount);
                    }
                }
                else
                {
                    data.savedSlots[i] = null;
                }
            }

            ItemSaveIO.SaveItems(data, gameObject.name);
        }
示例#2
0
        public void LoadInventory()
        {
            ContainerSaveData data = ItemSaveIO.LoadItems(gameObject.name);

            if (data == null)
            {
                return;
            }
            ItemData[] idata = new ItemData[data.savedSlots.Length];

            for (int i = 0; i < data.savedSlots.Length; i++)
            {
                if (data.savedSlots[i] != null)
                {
                    Item item = itemDatabase.GetItemCopy(data.savedSlots[i].itemID);
                    idata[i] = new ItemData(item, data.savedSlots[i].amount);
                }
            }

            items = idata;
        }
示例#3
0
 public static void SaveItems(TInv.ContainerSaveData items, string path)
 {
     FileReadWrite.WriteToBinaryFile(baseSavePath + "/" + path + ".dat", items);
 }