public ItemData GetRandomItemDataStepped() //Very steep odds, not as likely to get good gear. { float probablility = Random.Range(0, 100); float odds = Random.Range(0, 100); ItemData.eItemRarity rarity = ItemData.eItemRarity.COMMON; if (odds < probablility * (1 * .20)) { rarity = ItemData.eItemRarity.LEGENDARY; } else if (odds < probablility * (1 * .25)) { rarity = ItemData.eItemRarity.EPIC; } else if (odds < probablility * (1 * 0.33)) { rarity = ItemData.eItemRarity.RARE; } else if (odds < probablility * (1 * 0.5)) { rarity = ItemData.eItemRarity.UNCOMMON; } else { rarity = ItemData.eItemRarity.COMMON; } return(GetRandomItemWithRarity(rarity)); }
public ItemData GetRandomItemDataWeighted() // Better odds, more even possibilities. { float probablility = Random.Range(0, 100); ItemData.eItemRarity rarity = ItemData.eItemRarity.COMMON; if (probablility > 98) { rarity = ItemData.eItemRarity.LEGENDARY; } else if (probablility > 90) { rarity = ItemData.eItemRarity.EPIC; } else if (probablility > 75) { rarity = ItemData.eItemRarity.RARE; } else if (probablility > 50) { rarity = ItemData.eItemRarity.UNCOMMON; } else { rarity = ItemData.eItemRarity.COMMON; } return(GetRandomItemWithRarity(rarity)); }
public ItemData GetRandomItemWithRarity(ItemData.eItemRarity rarity) { ItemData[] itemsWithRarity = Items.Where(e => e.rarity == rarity).ToArray(); return(itemsWithRarity[Random.Range(0, itemsWithRarity.Length)]); }