public LootDrop(Item.ItemObjects _ItemObject, int _Weight) { this.ItemObject = _ItemObject; this.Weight = _Weight; }
public List <Item> GetEquipDrop(int ItemAmount) { List <Item> DropItems = new List <Item>(); int weightSum = 0; var RolledItemType = Item.ItemTypes.Gear; for (int amount = 1; amount <= ItemAmount; amount++) { //Rolling ItemObject int roll = Random.Range(0, 101); foreach (LootDrop drop in loot) { weightSum += drop.Weight; if (roll < weightSum) { //Rolled ItemObject var RolledItemObject = drop.ItemObject; //Rolling GearType Random No. from list Item.ItemObjects type = drop.ItemObject; var RolledGearType = Item.itemToGearTypes[type][Random.Range(0, Item.itemToGearTypes[type].Count)]; //Get Some Stuff From Item "Database" (e.g. obect_slug) Item NowGotItem = ItemDatabase.Instance.GetItem(RolledGearType); //Rolling Rarity ItemRarity = new RareTable(); ItemRarity.rarloot = new List <RarityDrop> { //No Common if no roll on Magic or rare or Legendary then it is a Common new RarityDrop(Item.Rarities.Magic, 25), new RarityDrop(Item.Rarities.Rare, 15), new RarityDrop(Item.Rarities.Legendary, 5), }; var RolledRarity = ItemRarity.GetRarityDrop(); //ItemLevel rewriting it to a curve //TODO PlayerLevel PlayerLevel = new PlayerLevel(); int PlayerLvl = PlayerLevel.Level; Debug.Log("Player LEVEL: " + PlayerLvl); int RolledItemLevel = Random.Range(PlayerLvl - 3, PlayerLvl + 3); //get min max suffix and roll rnd amount of suffixes KeyValuePair <int, int> minmaxsuffix = GetSuffixForRarity(RolledRarity); int minsuffix = minmaxsuffix.Key; int maxsuffix = minmaxsuffix.Value; int rolledSuffixAmount = Random.Range(minsuffix, maxsuffix); List <BaseStat> RolledSuffixStats = new List <BaseStat>(); BaseStat.BaseStatType[] allBaseStatTypes = (BaseStat.BaseStatType[])System.Enum.GetValues(typeof(BaseStat.BaseStatType)); for (int i = 1; i <= rolledSuffixAmount; i++) { BaseStat.BaseStatType BaseStatType = allBaseStatTypes[Random.Range(0, allBaseStatTypes.Length)]; int rolledBaseStatValue = 0; foreach (BaseStat a in NowGotItem.BaseSuffixStats) { if (a.StatType == BaseStatType) { rolledBaseStatValue = GetCalculatedMath(a.BaseValue, RolledItemLevel); } } BaseStat rolledBaseStat = new BaseStat(BaseStatType, rolledBaseStatValue, ""); RolledSuffixStats.Add(rolledBaseStat); } List <BaseStat> CalculatedBaseStats = new List <BaseStat>(); foreach (BaseStat a in NowGotItem.BaseSuffixStats) { int calulatedBaseStatValue = GetCalculatedMath(a.BaseValue, RolledItemLevel); BaseStat rolledBaseStat = new BaseStat(a.StatType, calulatedBaseStatValue, a.StatDescription); CalculatedBaseStats.Add(rolledBaseStat); } //Get Some Stuff From Item "Database" (e.g. obect_slug) Item NowRolledItem = new Item( RolledItemType, RolledItemObject, RolledGearType, RolledRarity, CalculatedBaseStats, new List <BaseStat>(), RolledSuffixStats, RolledItemLevel, NowGotItem.ObjectSlug, NowGotItem.Description, NowGotItem.ActionName, NowGotItem.ItemName, NowGotItem.IsStackable ); DropItems.Add(NowRolledItem); break; } } } return(DropItems); }