public EquipmentSaveData(EquipmentUI _equipment)
    {
        List <ItemDefensiveStatsSaveData> itemDefList = new List <ItemDefensiveStatsSaveData>();
        List <ItemOffensiveStatsSaveData> itemOffList = new List <ItemOffensiveStatsSaveData>();
        List <ItemCapacitySaveData>       itemCapList = new List <ItemCapacitySaveData>();

        foreach (EquipmentSlot slot in _equipment.slots)
        {
            Item item = slot.item;
            if (item != null)
            {
                if (item is Item_DefensiveStats)
                {
                    Item_DefensiveStats itemDef = item as Item_DefensiveStats;
                    itemDefList.Add(itemDef.ToSaveData());
                }
                else if (item is Item_OffensiveStats)
                {
                    Item_OffensiveStats itemOff = item as Item_OffensiveStats;
                    itemOffList.Add(itemOff.ToSaveData());
                }
                else if (item is Item_Skill)
                {
                    Item_Skill itemOff = item as Item_Skill;
                    itemCapList.Add(itemOff.ToSaveData());
                }
            }
        }

        itemDefensives = itemDefList.ToArray();
        itemOffensives = itemOffList.ToArray();
        itemCapacities = itemCapList.ToArray();
    }
Exemplo n.º 2
0
    public InventorySaveData(Inventory _inventory)
    {
        moneyAmount   = _inventory.MoneyAmount;
        slotAvailable = _inventory.slotsAvailable;

        List <ItemDefensiveStatsSaveData> itemDefList = new List <ItemDefensiveStatsSaveData>();
        List <ItemOffensiveStatsSaveData> itemOffList = new List <ItemOffensiveStatsSaveData>();
        List <ItemCapacitySaveData>       itemCapList = new List <ItemCapacitySaveData>();

        foreach (Item item in _inventory.items)
        {
            if (item is Item_DefensiveStats)
            {
                Item_DefensiveStats itemDef = item as Item_DefensiveStats;
                itemDefList.Add(itemDef.ToSaveData());
            }
            else if (item is Item_OffensiveStats)
            {
                Item_OffensiveStats itemOff = item as Item_OffensiveStats;
                itemOffList.Add(itemOff.ToSaveData());
            }
            else if (item is Item_Skill)
            {
                Item_Skill itemOff = item as Item_Skill;
                itemCapList.Add(itemOff.ToSaveData());
            }
        }

        itemDefensives = itemDefList.ToArray();
        itemOffensives = itemOffList.ToArray();
        itemCapacities = itemCapList.ToArray();
    }