Ejemplo n.º 1
0
    private void SaveItems(IList <ItemSlot> itemSlots, string fileName, int currencyAmount)
    {
        var saveData = new ItemContainerSaveData(itemSlots.Count, currencyAmount);

        for (int i = 0; i < saveData.SavedSlots.Length; i++)
        {
            ItemSlot itemSlot = itemSlots[i];

            if (itemSlot.item == null)
            {
                saveData.SavedSlots[i] = null;
            }
            else
            {
                //Debug.Log("Saving " + itemSlot.item.ID + " to slot " + i);
                saveData.SavedSlots[i] = new ItemSlotSaveData(itemSlot.item.ID, itemSlot.quantity);

                if (itemSlot.item as EquipmentItem)
                {
                    //Debug.Log("Saving Equipment Item...");
                    saveData.SavedSlots[i].itemData = (itemSlot.item as EquipmentItem).itemData;
                }
            }
        }

        ItemSaveIO.SaveItems(saveData, fileName);
    }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
    public void AddItemToList()
    {
        DateTime now = DateTime.Now.Date;

        System.Random r    = new System.Random();
        int           rInt = r.Next(0, 100);


        MyConfiguration myConfiguration = new MyConfiguration(now.ToShortDateString(), model.text, rInt.ToString());

        menuManager.myConfigs.Add(myConfiguration);
        ItemSaveIO.SaveItems(menuManager.myConfigs, "configurations");

        WriteData(rInt);
    }
Ejemplo n.º 4
0
    public void RewordItemToInventory()
    {
        int rewordItemCount = rewordItemArray.Length - 1;

        ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(InventoryFileName);

        if (savedSlots == null)
        {
            savedSlots = new ItemContainerSaveData(PlayerDataManager.Inst.GetPlayerData().inventoySize);

            for (int i = 0; i < rewordItemArray.Length; i++)
            {
                savedSlots.savedSlots[i] = new ItemSlotSaveData(rewordItemArray[rewordItemCount - i].ID, 1, SLOT_STATE.NOT_MOUNTING);
            }

            ItemSaveIO.SaveItems(savedSlots, InventoryFileName);
            return;
        }

        //저장할 공간
        var tempSaveData = new ItemContainerSaveData(savedSlots.savedSlots.Length);

        for (int i = 0; i < savedSlots.savedSlots.Length; i++)
        {
            ItemSlotSaveData savedSlot = savedSlots.savedSlots[i];

            if (savedSlot == null)
            {
                if (rewordItemCount >= 0)
                {
                    tempSaveData.savedSlots[i] = new ItemSlotSaveData(rewordItemArray[rewordItemCount].ID, 1, SLOT_STATE.NOT_MOUNTING);

                    rewordItemCount--;
                }
                else
                {
                    tempSaveData.savedSlots[i] = null;
                }
            }
            else
            {
                tempSaveData.savedSlots[i] = new ItemSlotSaveData(savedSlot.itemID, savedSlot.amount, savedSlot.slotState);
            }
        }

        ItemSaveIO.SaveItems(tempSaveData, InventoryFileName);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Saves data of item slots in the given filename.
    /// </summary>
    /// <param name="itemSlots"></param>
    /// <param name="fileName"></param>
    private void SaveItems(IList <ItemSlot> itemSlots, string fileName)
    {
        var saveData = new ItemContainerSaveData(itemSlots.Count);

        for (int i = 0; i < itemSlots.Count; i++)
        {
            ItemSlot slot = itemSlots[i];
            if (slot.Item == null)
            {
                saveData.SavedSlots[i] = null;
            }
            else
            {
                saveData.SavedSlots[i] = new ItemSlotSaveData(slot.Item.Id);
            }
        }
        ItemSaveIO.SaveItems(saveData, fileName);
    }
    private void SaveItems(IList <ItemSlot> itemSlots, string fileName)
    {
        //Debug.Log(itemSlots[0].Item.ItemName);
        var saveData = new ItemContainerSaveData(itemSlots.Count);

        for (int i = 0; i < saveData.SavedSlots.Length; i++)
        {
            ItemSlot itemSlot = itemSlots[i];
            if (itemSlot.Item == null)
            {
                saveData.SavedSlots[i] = null;
            }
            else
            {
                saveData.SavedSlots[i] = new ItemSlotSaveData(itemSlot.Item.ID, itemSlot.Amount);
            }
        }
        ItemSaveIO.SaveItems(saveData, fileName);
    }
Ejemplo n.º 7
0
    private void SaveEquipmentItems(IList <ItemSlot> _itemSlots, string _fileName)
    {
        var saveData = new ItemContainerSaveData(_itemSlots.Count);

        for (int i = 0; i < saveData.savedSlots.Length; i++)
        {
            ItemSlot itemSlot = _itemSlots[i];

            if (itemSlot.Item == null)
            {
                saveData.savedSlots[i] = null;
            }
            else
            {
                saveData.savedSlots[i] = new ItemSlotSaveData(itemSlot.Item.ID, itemSlot.Amount, itemSlot.eSlotState, ((EquipmentSlot)itemSlot).rememberInventoryIndex);
            }
        }

        ItemSaveIO.SaveItems(saveData, _fileName);
    }