Example #1
0
    public PlayerDataManager.PlayerData LoadPlayerEquipmentStatusSetting(PlayerDataManager.PlayerData _playerData)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(EquipmentFileName);

        if (savedSlots == null)
        {
            return(_playerData);
        }

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

            if (savedSlot == null)
            {
            }
            else
            {
                EquippableItem equipItem = (EquippableItem)m_itemDataBase.GetItemReference(savedSlot.itemID);

                _playerData.attack    += equipItem.attackBonus;
                _playerData.defensive += equipItem.armorBonus;
                _playerData.maxHp     += equipItem.maxHealthBonus;
            }
        }
        return(_playerData);
    }
Example #2
0
    public void LoadInventory(InventoryManger _inventoryManager)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(InventoryFileName);

        if (savedSlots == null)
        {
            return;
        }

        _inventoryManager.inventory.Clear();

        for (int i = 0; i < savedSlots.savedSlots.Length; i++)
        {
            ItemSlot         itemSlot  = _inventoryManager.inventory.itemSlots[i];
            ItemSlotSaveData savedSlot = savedSlots.savedSlots[i];

            if (savedSlot == null)
            {
                itemSlot.Item   = null;
                itemSlot.Amount = 0;
            }
            else
            {
                itemSlot.Item       = m_itemDataBase.GetItemCopy(savedSlot.itemID);
                itemSlot.Amount     = savedSlot.amount;
                itemSlot.eSlotState = savedSlot.slotState;
                itemSlot.SetStart();
            }
        }
    }
Example #3
0
    public void LoadEquipment(InventoryManger _inventoryManager)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(EquipmentFileName);

        if (savedSlots == null)
        {
            return;
        }

        for (int i = 0; i < savedSlots.savedSlots.Length; i++)
        {
            ItemSlot         itemSlot  = _inventoryManager.equipmentPanel.equipmentSlots[i];
            ItemSlotSaveData savedSlot = savedSlots.savedSlots[i];

            if (savedSlot == null)
            {
                itemSlot.Item   = null;
                itemSlot.Amount = 0;
            }
            else
            {
                itemSlot.Item   = m_itemDataBase.GetItemCopy(savedSlot.itemID);
                itemSlot.Amount = savedSlot.amount;
                ((EquipmentSlot)itemSlot).rememberInventoryIndex = savedSlot.rememberInventoryIndex;
                itemSlot.eSlotState = savedSlot.slotState;
                itemSlot.SetStart();
            }
        }
    }
Example #4
0
    public void LoadItemStash(ItemStashWindow itemStashWindow, string ItemStashID)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO._LoadItems(ItemStashID);

        if (savedSlots == null)
        {
            return;
        }
        itemStashWindow.Clear();

        for (int i = 0; i < savedSlots.SavedSlots.Length; i++)
        {
            ItemSlot         itemSlot  = itemStashWindow.itemSlots[i];
            ItemSlotSaveData savedSlot = savedSlots.SavedSlots[i];

            if (savedSlot == null)
            {
                itemSlot.Item   = null;
                itemSlot.Amount = 0;
            }
            else
            {
                itemSlot.Item   = itemDatabase.GetItemCopy(savedSlot.ItemID);
                itemSlot.Amount = savedSlot.Amount;
            }
        }
    }
Example #5
0
    public void LoadInventory(Character character)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO._LoadItems(InventoryFileName);

        if (savedSlots == null)
        {
            return;
        }
        character.inventory.Clear();

        for (int i = 0; i < savedSlots.SavedSlots.Length; i++)
        {
            ItemSlot         itemSlot  = character.inventory.itemSlots[i];
            ItemSlotSaveData savedSlot = savedSlots.SavedSlots[i];

            if (savedSlot == null)
            {
                itemSlot.Item   = null;
                itemSlot.Amount = 0;
            }
            else
            {
                itemSlot.Item   = itemDatabase.GetItemCopy(savedSlot.ItemID);
                itemSlot.Amount = savedSlot.Amount;
            }
        }
    }
Example #6
0
 public void AddItems(List <Item> items)
 {
     for (int i = 0; i < items.Count; i++)
     {
         Item currItem = items[i];
         savedSlots[i] = new ItemSlotSaveData(currItem.ID, 1);
     }
 }
Example #7
0
 public void AddItems(List <ItemSlotData> occupiedItemSlots)
 {
     for (int i = 0; i < occupiedItemSlots.Count; i++)
     {
         Item currItem = occupiedItemSlots[i].Item;
         savedSlots[i] = new ItemSlotSaveData(currItem.ID, occupiedItemSlots[i].Amount);
     }
 }
Example #8
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);
    }
    public void LoadInventory(Inventory inventory)
    {
        //Debug.Log("Loading Inventory...");
        ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(InventoryFileName);

        inventory.Money = savedSlots.Money;
        if (savedSlots == null)
        {
            return;
        }

        inventory.Clear(); //Clear inventory

        for (int i = 0; i < savedSlots.SavedSlots.Length; i++)
        {
            //ItemSlot itemSlot = inventory.ItemContainer.itemSlots[i];
            ItemSlot         itemSlot;
            ItemSlotSaveData savedSlot = savedSlots.SavedSlots[i];

            if (savedSlot == null)
            {
                itemSlot.item     = null;
                itemSlot.quantity = 0;
            }
            else
            {
                itemSlot.item     = itemDatabase.GetItemCopy(savedSlot.ItemID);
                itemSlot.quantity = savedSlot.Amount;
                inventory.ItemContainer.AddItemAt(itemSlot, i);

                if (itemSlot.item as EquipmentItem)
                {
                    (itemSlot.item as EquipmentItem).itemData = savedSlot.itemData;
                }
            }
        }

        if (savedSlots.SavedSlots[17] != null)
        {
            //Debug.Log("Loading Equipped Weapon from Save File...");
            uiCharacterEquipment.loadEquippedItems();
        }
    }
Example #10
0
    /// <summary>
    /// Loads state of the inventory.
    /// </summary>
    /// <param name="character"></param>
    public void LoadInventory(Character character)
    {
        ItemContainerSaveData savedInventorySlots = ItemSaveIO.LoadItems(InventoryFileName);

        if (savedInventorySlots != null)
        {
            character.InventoryManager.Inventory.Clear();
            for (int i = 0; i < savedInventorySlots.SavedSlots.Length; i++)
            {
                ItemSlot         itemSlot  = character.InventoryManager.Inventory.ItemSlots[i];
                ItemSlotSaveData savedSlot = savedInventorySlots.SavedSlots[i];

                itemSlot.Item = (savedSlot != null) ? itemConfig.GetItemClone(savedSlot.ItemId) : null;
                if (itemSlot.Item != null)
                {
                    character.InventoryManager.Inventory.AddItem(itemSlot.Item);
                }
            }
        }
    }