Exemple #1
0
        public void Reroll()
        {
            if (previouseSelectedSlot == null || previouseSelectedSlot.GetModifier() == null)
            {
                return;
            }

            //get mod and pay price
            ModifiableItem.Modifier mod = previouseSelectedSlot.GetModifier();
            int price = (itemSlot.item.rarity == Rank.Rare && mod.rarity == Rank.Normal) ? rerollPrices[1] : rerollPrices[(int)mod.rarity];
            int payed = playerInventory.GetGems(price);

            if (payed == 0)
            {
                return;
            }

            int index = (itemSlot.item as ModifiableItem).modifiers.IndexOf(mod);

            (itemSlot.item as ModifiableItem).modifiers.Remove(mod);

            //get baseModifier
            GenericItem      baseItem = GenericItem.GetFromID(itemSlot.item.itemID);
            ItemStatModifier baseMod;

            do
            {
                baseMod = baseItem.GetRandomModifier(mod.rarity);
            }while ((itemSlot.item as ModifiableItem).modifiers.Find(x => x.name == baseMod.name) != null);

            ModifiableItem.Modifier newMod = new ModifiableItem.Modifier(baseMod, baseItem.modifierQuality);

            //upgrade modifier if rerolled modifier was rare
            if (itemSlot.item.rarity == Rank.Rare && mod.rarity == Rank.Normal)
            {
                newMod.value *= 1 + PlayerInfo.GetGlobalParameters().rareValueImprovement;
            }



            (itemSlot.item as ModifiableItem).modifiers.Insert(index, newMod);
            LoadModifiers(itemSlot.item);
            FindObjectOfType <SavingSystem>().Save("PlayerData", SaveType.All);
        }
Exemple #2
0
        public void SelectModifier(EnchantmentModifierSlot slot)
        {
            HandleSelectionColor(slot);

            ModifiableItem.Modifier mod = slot.GetModifier();

            if (mod == null)
            {
                rerollBtn.text = "Reroll for 0";
                return;
            }
            if (itemSlot.item.rarity == Rank.Rare && mod.rarity == Rank.Normal)
            {
                rerollBtn.text = "Reroll for " + rerollPrices[1];
            }
            else
            {
                rerollBtn.text = "Reroll for " + rerollPrices[(int)mod.rarity];
            }
        }