public Lootbox CreateLootbox(int size = 3) { Lootbox lb = new Lootbox(size); for (int i = 0; i < size; i++) { var r = RarityHelper.GetWeightedRarity(); LootboxItem item = null; int retardCheck = 0; do { repeat: item = PotentialRewards.RandomElement(x => x.Rarity == r); if (item.RewardType == LootboxRewardType.Generators && !Services.TransportService.HasUnits(item.TargetGenerator)) { goto repeat; } r--; // if not item of that rarity was found, go one lower retardCheck++; if (retardCheck > 10) { break; } } while (item == null && r > 0); lb[i] = item; } return(lb); }
private void ActivateLootboxItem(LootboxItem lbi, LootboxItemView view) { if (lbi == null) { //TEMP placeholders lbi = new LootboxItem(); lbi.Rarity = RarityHelper.GetWeightedRarity(); lbi.DescText = "Temp Item"; } view.Rarity = lbi.Rarity; view.DescText.text = lbi.DescText; view.Sprite = lbi.Icon; view.gameObject.SetActive(true); }