Exemplo n.º 1
0
 private Item runRandAndList(List <Item> list)
 {
     total = 0;
     foreach (var item in list)
     {
         total += item.Rarity;
     }
     rand = Random.Range(0, total);
     foreach (var itemWeight in list)
     {
         if (rand <= itemWeight.Rarity)
         {
             //award item
             Debug.Log("Award: " + itemWeight.ItemName + " - " + itemWeight.Rarity + " - " + itemWeight.RarityType);
             inventory.GiveItem(itemWeight.ObjectSlug);
             UIEventHandler.ItemPulled(itemWeight);
             return(itemWeight);
         }
         else
         {
             rand -= itemWeight.Rarity;
         }
     }
     Debug.Log("Return Null");
     return(null);
 }