Example #1
0
        List <ItemData> RandomizeLootBox(SurpriseMechanics selectedLootBox)
        {
            List <ItemData> AcquiredLoot = new List <ItemData>();

            for (int i = 0; i < selectedLootBox.LootAmount; i++)
            {
                AcquiredLoot.Add(CalculateItemDrop(selectedLootBox));
            }

            if (AcquiredLoot.Count != selectedLootBox.LootAmount)
            {
                Debug.LogError("Lootbox loot amount was not the right amount");
                return(null);
            }

            return(AcquiredLoot);
        }
Example #2
0
        ItemData CalculateItemDrop(SurpriseMechanics selectedLootBox)
        {
            Rarity selectedRarity = Rarity.Common;

            float rand = Random.value;

            for (int i = selectedLootBox.ContainedRarities.Length - 1; i >= 0; i--)
            {
                if (selectedLootBox.ContainedRarities[i].chance >= rand)
                {
                    selectedRarity = selectedLootBox.ContainedRarities[i].rarity;
                    break;
                }
            }

            ItemData acquiredItem = null;

            switch (selectedRarity)
            {
            case Rarity.Common:
                acquiredItem = GetRandomItem(CommonItemDatabase);
                break;

            case Rarity.Rare:
                acquiredItem = GetRandomItem(RareItemDatabase);
                break;

            case Rarity.Epic:
                acquiredItem = GetRandomItem(EpicItemDatabase);
                break;

            case Rarity.Legendary:
                acquiredItem = GetRandomItem(LegendaryItemDatabase);
                break;
            }

            Debug.Log("Acquired: " + acquiredItem.ItemName + " of rarity " + acquiredItem.ItemRarity + ", item type " + acquiredItem.ItemLootType);

            if (acquiredItem != null)
            {
                return(acquiredItem);
            }

            return(null);
        }
Example #3
0
 public List <ItemData> InitializeLootbox(SurpriseMechanics selectedLootBox)
 {
     return(RandomizeLootBox(selectedLootBox));
 }
Example #4
0
 public List <ItemData> InitializeLootbox(SurpriseMechanics selectedLootBox)
 {
     LootManager.Instance.OpenedBoxes++;
     return(RandomizeLootBox(selectedLootBox));
 }