public PlayerItem getRandomItem(int stageNumber) { int r = UnityEngine.Random.Range(0, allItemsInGame.Count); PlayerItem item = new PlayerItem(allItemsInGame[r], stageNumber); if (item.type == ItemType.Body) { //Potion item.addModifier(new PotionModifier(1)); item.consumable = true; return(item); } int modifCap = UnityEngine.Random.Range(1, Mathf.Min(4, stageNumber)); item.rarity = modifCap; for (int i = 0; i < modifCap; ++i) { int rarityModifier = 0; if (UnityEngine.Random.value > 0.99) { Debug.Log("WAow +1"); rarityModifier = 1; item.rarity += 1; } item.addModifier(ItemModifierEffect.getRandomModifierOfLevel(stageNumber - i + rarityModifier)); } return(item); }
public void addModifier(ItemModifierEffect modifier) { ItemModifierEffect same = null; bool found = false; for (int i = 0; i < modifiers.Count && !found; ++i) { if (modifiers[i].modifierType == modifier.modifierType) { found = true; same = modifiers[i]; } } if (found) { same.finalAmount += modifier.finalAmount; } else { modifiers.Add(modifier); } }