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(); }
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(); }
void UpdateRarity(ref Item_OffensiveStats item) { GameDifficulty _gameDifficulty = GameManager.Singleton.gameData.GetGameDifficulty(); float maxValue = 100; foreach (RaritiesPerGameDifficuty.RarityData currentRarity in item.raritiesPerDifficulty[(int)_gameDifficulty].rarities) { currentRarity.SetRarityBounds(ref maxValue); } float rarityRoll = Random.Range(0, 10001) / 100f; foreach (RaritiesPerGameDifficuty.RarityData currentRarity in item.raritiesPerDifficulty[(int)_gameDifficulty].rarities) { if (rarityRoll >= currentRarity.minValue && rarityRoll <= currentRarity.maxValue) { ItemRarityData rarityData = raritiesDatas[(int)currentRarity.itemRarity]; item.rarityStr = rarityData.name; item.name += " (" + item.rarityStr + ")"; rarityData.statAlteration.GenerateFinalValue(); item.statAlteration = rarityData.statAlteration; SetItemPrices(ref item, rarityData); break; } } }
public void SetItemPrices(ref Item_OffensiveStats item, ItemRarityData rarity) { float sellPriceGap; float buyPriceGap; sellPriceGap = rarity.maxSellPrice - rarity.minSellPrice; buyPriceGap = rarity.maxBuyPrice - rarity.minBuyPrice; item.sellPrice = Mathf.FloorToInt(rarity.minSellPrice + (sellPriceGap * item.statAlteration.finalValue) / item.statAlteration.maxValue); item.buyPrice = Mathf.CeilToInt(rarity.minBuyPrice + (buyPriceGap * item.statAlteration.finalValue) / item.statAlteration.maxValue); }
public void SetItemInfo(Item item, PriceType priceType) { canvasGroup.alpha = 1; itemName.text = item.name; if (item is Item_DefensiveStats) { Item_DefensiveStats _item = item as Item_DefensiveStats; itemType.text = _item.statAlteration.TypeToString(); itemStatValue.text = _item.statAlteration.finalValue.ToString(); itemDescription.text = ""; } else if (item is Item_OffensiveStats) { Item_OffensiveStats _item = item as Item_OffensiveStats; itemType.text = _item.statAlteration.TypeToString(); itemStatValue.text = _item.statAlteration.finalValue.ToString(); itemDescription.text = ""; } else if (item is Item_Skill) { Item_Skill _item = item as Item_Skill; itemType.text = ""; itemStatValue.text = ""; itemDescription.text = _item.skill.GetDescription(); } // Price display if (priceType == PriceType.Sell) { priceTypeText.text = "Prix de vente"; priceValueText.text = item.sellPrice.ToString(); } else { priceTypeText.text = "Prix d'achat"; priceValueText.text = item.buyPrice.ToString(); } }
// ----------------------------------------------------------------------- ** void UpdatePlayerStats(Item item, bool equip) { if (item is Item_DefensiveStats) { Item_DefensiveStats itemDef = item as Item_DefensiveStats; if (equip) { switch (itemDef.statAlteration.type) { case DefensiveStatsAlteration.ModificationType.HealthMax: player.stats.healthMax += itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.HealthRegen: player.stats.healthRegen += itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.StaminaMax: player.stats.staminaMax += itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.StaminaRegen: player.stats.staminaRegen += itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.Armor: player.stats.armor += itemDef.statAlteration.finalValue; break; default: break; } } else { switch (itemDef.statAlteration.type) { case DefensiveStatsAlteration.ModificationType.HealthMax: player.stats.healthMax -= itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.HealthRegen: player.stats.healthRegen -= itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.StaminaMax: player.stats.staminaMax -= itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.StaminaRegen: player.stats.staminaRegen -= itemDef.statAlteration.finalValue; break; case DefensiveStatsAlteration.ModificationType.Armor: player.stats.armor -= itemDef.statAlteration.finalValue; break; default: break; } } hudManager.statsDisplayer.UpdateStats(); } else if (item is Item_OffensiveStats) { Item_OffensiveStats itemOff = item as Item_OffensiveStats; if (equip) { switch (itemOff.statAlteration.type) { case OffensiveStatsAlteration.ModificationType.NormalDamage: player.stats.normalDamages += itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CapacityDamage: player.stats.capacitiesDamagesM += itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CooldownReduction: player.stats.cooldownReduction += itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CriticalDamage: player.stats.criticalDamagesM += itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CriticalChance: player.stats.criticalChances += itemOff.statAlteration.finalValue; break; default: break; } } else { switch (itemOff.statAlteration.type) { case OffensiveStatsAlteration.ModificationType.NormalDamage: player.stats.normalDamages -= itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CapacityDamage: player.stats.capacitiesDamagesM -= itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CooldownReduction: player.stats.cooldownReduction -= itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CriticalDamage: player.stats.criticalDamagesM -= itemOff.statAlteration.finalValue; break; case OffensiveStatsAlteration.ModificationType.CriticalChance: player.stats.criticalChances -= itemOff.statAlteration.finalValue; break; default: break; } } hudManager.statsDisplayer.UpdateStats(); } }