private Item LoadOffensiveItem(ItemOffensiveStatsSaveData _data, ItemsDataBase _itemsDataBase) { OffensiveStatsAlteration.ModificationType statType = (OffensiveStatsAlteration.ModificationType)_data.statType; Item offItem = null; switch (statType) { case OffensiveStatsAlteration.ModificationType.NormalDamage: offItem = _itemsDataBase.normalDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CapacityDamage: offItem = _itemsDataBase.capacitiesDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CooldownReduction: offItem = _itemsDataBase.cooldownReduction.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CriticalDamage: offItem = _itemsDataBase.critDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CriticalChance: offItem = _itemsDataBase.critChances.FromSaveData(_data); break; default: break; } return(offItem); }
/// <summary> /// Crete an item based on the datas of a saved item. /// </summary> /// <param name="_data"></param> public Item FromSaveData(ItemOffensiveStatsSaveData _data) { Item_OffensiveStats instance; OffensiveStatsAlteration _statsAlteration; instance = Instantiate(this) as Item_OffensiveStats; instance.name = _data.name; instance.rarityStr = _data.rarity; instance.isSaved = _data.isSaved == 1; instance.isEquiped = _data.isEquiped == 1; instance.slotIndex = _data.slotIndex; _statsAlteration = new OffensiveStatsAlteration(); _statsAlteration.type = (OffensiveStatsAlteration.ModificationType)_data.statType; _statsAlteration.finalValue = _data.statsValue; instance.statAlteration = _statsAlteration; instance.sellPrice = _data.sellPrice; instance.buyPrice = _data.buyPrice; return(instance); }
/// <summary> /// Copy the current item to a saveable item. /// </summary> /// <returns></returns> public ItemOffensiveStatsSaveData ToSaveData() { ItemOffensiveStatsSaveData data; data = new ItemOffensiveStatsSaveData(); data.name = name; data.rarity = rarityStr; data.itemType = (int)type; data.isSaved = isSaved ? 1 : 0; data.isEquiped = isEquiped ? 1 : 0; data.slotIndex = slotIndex; data.statType = (int)statAlteration.type; data.statsValue = statAlteration.finalValue; data.sellPrice = sellPrice; data.buyPrice = buyPrice; return(data); }