Exemplo 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);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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;
            }
        }
    }
Exemplo n.º 4
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();
            }
        }
    }
Exemplo n.º 5
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;
            }
        }
    }
Exemplo n.º 6
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();
            }
        }
    }
Exemplo n.º 7
0
 public UnitSaveData(string name, string classInput, int numItems, int unitLevelInput, int unitExpInput, Dictionary <StatString, int> stats, List <string> abilities)
 {
     unitName      = name;
     unitClass     = classInput;
     unitLevel     = unitLevelInput;
     unitExp       = unitExpInput;
     unitInventory = new ItemContainerSaveData(numItems);
     unitStats     = stats;
     unitAbilities = abilities;
 }
Exemplo n.º 8
0
 public UnitSaveData(UnitSaveData oldUnitSaveData, List <Item> items, Dictionary <StatString, int> stats)
 {
     unitName      = oldUnitSaveData.unitName;
     unitClass     = oldUnitSaveData.unitClass;
     unitLevel     = oldUnitSaveData.unitLevel;
     unitExp       = oldUnitSaveData.unitExp;
     unitInventory = new ItemContainerSaveData(items.Count);
     unitInventory.AddItems(items);
     unitStats     = stats;
     unitAbilities = oldUnitSaveData.unitAbilities;
 }
Exemplo n.º 9
0
 public UnitSaveData(string name, string classInput, Level unitLevel, List <ItemSlotData> itemSlots, Dictionary <StatString, int> stats, List <string> abilities)
 {
     unitName       = name;
     unitClass      = classInput;
     this.unitLevel = unitLevel.currentLevel;
     unitExp        = unitLevel.currentExperience;
     unitInventory  = new ItemContainerSaveData(itemSlots.Count);
     unitInventory.AddItems(itemSlots);
     unitStats     = stats;
     unitAbilities = abilities;
 }
Exemplo n.º 10
0
    public List <Item> LoadInventory(string fileName)
    {
        ItemContainerSaveData itemContainer = JsonSaveLoadIO.LoadItems(fileName);

        List <Item> items = new List <Item>();

        foreach (ItemSlotSaveData itemSlotSave in itemContainer.savedSlots)
        {
            if (itemSlotSave != null)
            {
                items.Add(itemDataBase.GetItemCopy(itemSlotSave.itemId));
            }
        }
        return(items);
    }
Exemplo n.º 11
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);
    }
Exemplo n.º 12
0
    // DANGEROUS BUT EASY DEFAULT TO AMOUNT = 1
    private void SaveItems(IList <Item> items, string fileName)
    {
        var saveData = new ItemContainerSaveData(items.Count);

        for (int i = 0; i < saveData.savedSlots.Length; i++)
        {
            if (items[i] == null)
            {
                saveData.savedSlots[i] = null;
            }
            else
            {
                saveData.savedSlots[i] = new ItemSlotSaveData(items[i].ID, 1);
            }
        }
        JsonSaveLoadIO.SaveItems(saveData, fileName);
    }
Exemplo n.º 13
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);
    }
Exemplo n.º 14
0
    private void SaveItems(IList <BaseInvSlot> itemSlots, string fileName)
    {
        var saveData = new ItemContainerSaveData(itemSlots.Count);

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

            if (itemSlot.ITEM == null)
            {
                saveData.SavedSlots[i] = null;
            }
            else
            {
                //saveData.SavedSlots[i] = new ItemSlotSaveData(itemSlot.ITEM.itemDefinition.ID(), itemSlot.Amount);
            }
        }
        SaveData(saveData, fileName);
    }
Exemplo n.º 15
0
    private void SaveItems(IList <ItemSlot> itemSlots, string fileName)
    {
        var saveData = new ItemContainerSaveData(itemSlots.Count);

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

            if (currSlot.Item == null)
            {
                saveData.savedSlots[i] = null;
            }
            else
            {
                saveData.savedSlots[i] = new ItemSlotSaveData(currSlot.Item.ID, currSlot.Amount);
            }
        }
        JsonSaveLoadIO.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);
    }
Exemplo n.º 17
0
    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();
        }
    }
Exemplo n.º 18
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);
    }
Exemplo n.º 19
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);
                }
            }
        }
    }
Exemplo n.º 20
0
    public void LoadEquipment(Character character)
    {
        ItemContainerSaveData savedSlots = ItemSaveIO._LoadItems(EquipmentFileName);

        if (savedSlots == null)
        {
            return;
        }
        foreach (ItemSlotSaveData savedSlot in savedSlots.SavedSlots)
        {
            if (savedSlot == null)
            {
                continue;
            }

            Item item = itemDatabase.GetItemCopy(savedSlot.ItemID);
            character.inventory.AddItem(item);
            character.Equip((EquippableItem)item);
        }
    }
    private void SaveItems(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, 1); // TODO: Addin BaseItemSlot Enchant
                Debug.Log("Save to database: " + itemSlot.Item.itemId + " | " + itemSlot.Amount + " | equiped or not |" + " enchant lvl");
            }
        }

        Debug.Log("Inventory Manager save data TODO");
    }
Exemplo n.º 22
0
    /// <summary>
    /// Loads state of the equipments.
    /// </summary>
    /// <param name="character"></param>
    public void LoadEquipments(Character character)
    {
        ItemContainerSaveData savedEquipmentSlots = ItemSaveIO.LoadItems(EquipmentFileName);

        if (savedEquipmentSlots == null)
        {
            return;
        }

        foreach (ItemSlotSaveData savedSlot in savedEquipmentSlots.SavedSlots)
        {
            if (savedSlot == null)
            {
                continue;
            }

            Item item = (savedSlot != null) ? itemConfig.GetItemClone(savedSlot.ItemId) : null;
            if (item != null)
            {
                character.InventoryManager.Inventory.AddItem(item);
                character.Equip(item);
            }
        }
    }
Exemplo n.º 23
0
 public static void SaveItems(ItemContainerSaveData items, string fileName)
 {
     FileReadWrite.WriteToBinaryFile(baseSavePath + "/" + fileName + ".dat", items);
 }
Exemplo n.º 24
0
 public static void SaveItems(ItemContainerSaveData _items, string _path)
 {
     ItemFileReadWrite.WriteToBinaryFile(baseSavePath + "/" + _path + ".dat", _items);
 }
 public static void SaveItems(ItemContainerSaveData items, string fileName)
 {
     //Debug.Log(items.SavedSlots[0].itemID);
     FileReadWrite.WriteToBinaryFile(baseSavePath + "/" + fileName + ".dat", items);
 }
Exemplo n.º 26
0
 public static void SaveItems(ItemContainerSaveData itemContainerSaveData, string path)
 {
     JSONReadWrite.WriteToJsonFile(baseSavePath + "/" + path + ".json", itemContainerSaveData);
 }
Exemplo n.º 27
0
 private void SaveData(ItemContainerSaveData saveData, string fileName)
 {
     SaveLoad.Save(saveData, fileName);
 }
Exemplo n.º 28
0
    private void SetWeaponItem(HotbarItem weaponItem, bool isLoadingfromSave)
    {
        this.weaponItem = weaponItem;
        //Debug.Log("Weapon Slot: Currently Equiped " + weaponItem.name);

        if (LoadedWeapon)
        {
            PhotonNetwork.Destroy(LoadedWeapon);
        }

        if (isLoadingfromSave)
        {
            ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems("Inventory");
            if (savedSlots.SavedSlots[17] != null)
            {
                CurrentPlayer = PhotonNetwork.LocalPlayer.TagObject as GameObject;
                LoadedWeapon  = PhotonNetwork.Instantiate((Path.Combine("PhotonPrefabs/Items", savedSlots.SavedSlots[17].ItemID)), Vector3.up, Quaternion.identity) as GameObject;
                LoadedWeapon.transform.position = CurrentPlayer.transform.GetChild(1).GetChild(0).position;
                LoadedWeapon.transform.rotation = CurrentPlayer.transform.GetChild(1).GetChild(0).rotation;

                // if(PV.IsMine)
                //     PV.RPC("TransformLoadedWeapon", RpcTarget.All);
                TransformLoadedWeapon();
                //LoadedWeapon.transform.SetParent(CurrentPlayer.transform.GetChild(1).GetChild(0));
                //LoadedWeapon.transform.parent = CurrentPlayer.transform.GetChild(1).GetChild(0);

                LoadedWeapon.GetComponent <WeaponStats>().item_value    = savedSlots.SavedSlots[17].itemData.item_value;
                LoadedWeapon.GetComponent <WeaponStats>().attack        = savedSlots.SavedSlots[17].itemData.attack;
                LoadedWeapon.GetComponent <WeaponStats>().attack_speed  = savedSlots.SavedSlots[17].itemData.attack_speed;
                LoadedWeapon.GetComponent <WeaponStats>().crit_chance   = savedSlots.SavedSlots[17].itemData.crit_chance;
                LoadedWeapon.GetComponent <WeaponStats>().bleed_chance  = savedSlots.SavedSlots[17].itemData.bleed_chance;
                LoadedWeapon.GetComponent <WeaponStats>().range         = savedSlots.SavedSlots[17].itemData.range;
                LoadedWeapon.GetComponent <WeaponStats>().defense       = savedSlots.SavedSlots[17].itemData.defense;
                LoadedWeapon.GetComponent <WeaponStats>().magic_defense = savedSlots.SavedSlots[17].itemData.magic_defense;
                LoadedWeapon.GetComponent <WeaponStats>().move_speed    = savedSlots.SavedSlots[17].itemData.move_speed;
                LoadedWeapon.GetComponent <WeaponStats>().item_type     = savedSlots.SavedSlots[17].itemData.item_type;
            }
        }
        else
        {
            CurrentPlayer = PhotonNetwork.LocalPlayer.TagObject as GameObject;
            LoadedWeapon  = PhotonNetwork.Instantiate((Path.Combine("PhotonPrefabs/Items", weaponItem.Name)), Vector3.up, Quaternion.identity) as GameObject;
            LoadedWeapon.transform.position = CurrentPlayer.transform.GetChild(1).GetChild(0).position;
            LoadedWeapon.transform.rotation = CurrentPlayer.transform.GetChild(1).GetChild(0).rotation;

            // if(PV.IsMine)
            //     PV.RPC("TransformLoadedWeapon", RpcTarget.All); // RpcTarget.all
            TransformLoadedWeapon();
            //LoadedWeapon.transform.SetParent(CurrentPlayer.transform.GetChild(1).GetChild(0));
            //LoadedWeapon.transform.parent = CurrentPlayer.transform.GetChild(1).GetChild(0);

            equipmentItem = playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem;

            LoadedWeapon.GetComponent <WeaponStats>().item_value    = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.item_value;
            LoadedWeapon.GetComponent <WeaponStats>().attack        = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.attack;
            LoadedWeapon.GetComponent <WeaponStats>().attack_speed  = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.attack_speed;
            LoadedWeapon.GetComponent <WeaponStats>().crit_chance   = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.crit_chance;
            LoadedWeapon.GetComponent <WeaponStats>().bleed_chance  = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.bleed_chance;
            LoadedWeapon.GetComponent <WeaponStats>().range         = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.range;
            LoadedWeapon.GetComponent <WeaponStats>().defense       = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.defense;
            LoadedWeapon.GetComponent <WeaponStats>().magic_defense = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.magic_defense;
            LoadedWeapon.GetComponent <WeaponStats>().move_speed    = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.move_speed;
            LoadedWeapon.GetComponent <WeaponStats>().item_type     = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.item_type;
        }

        //LoadIntoHand(weaponItem, isLoadingfromSave);
    }