Exemple #1
0
        public void InitAffixes()
        {
            combined = new Prefix("Combined");

            float avgRand = 0f;
            float totalRand = 0f;
            foreach (GPrefix prefix in prefixes)
            {
                combined.pAdd.defense += prefix.pAdd.defense;
                combined.pAdd.crit += prefix.pAdd.crit;
                combined.pAdd.mana += prefix.pAdd.mana;
                combined.pAdd.damage += prefix.pAdd.damage;
                combined.pAdd.moveSpeed += prefix.pAdd.moveSpeed;
                combined.pAdd.meleeSpeed += prefix.pAdd.meleeSpeed;
                combined.pAdd.meleeDamage += prefix.pAdd.meleeDamage;
                combined.pAdd.rangedDamage += prefix.pAdd.rangedDamage;
                combined.pAdd.magicDamage += prefix.pAdd.magicDamage;
                combined.pAdd.meleeCrit += prefix.pAdd.meleeCrit;
                combined.pAdd.rangedCrit += prefix.pAdd.rangedCrit;
                combined.pAdd.magicCrit += prefix.pAdd.magicCrit;
                combined.playerMods.AddRange(prefix.playerMods);
                combined.itemMods.AddRange(prefix.itemMods);
                combined.customRequirements.AddRange(prefix.customRequirements);
                combined.toolTips.AddRange(prefix.toolTips);
                combined.dynamicTips.AddRange(prefix.dynamicTips);

                //'register' delegates
                foreach (string name in prefix.delegates.Keys)
                {
                    Delegate curDel = null;
                    item.delegates.TryGetValue(name, out curDel);
                    if (curDel != null)
                    {
                        Delegate newDel = Delegate.Combine(curDel, prefix.delegates[name]);
                        item.delegates[name] = newDel;
                    }
                    else item.delegates[name] = prefix.delegates[name];
                }

                avgRand += prefix.rarity;
                totalRand += 1f;
            }
            if (totalRand > 0f)
            {
                combined.AddTip("Rarity: " + avgRand);
                avgRand = avgRand / totalRand;
                int rare = Rand.SkewedRand(0, 6, avgRand);
                item.rare += rare;
            }
            item.prefix = 0;

            combined.Apply(item);
            if (item.rare < -1)
            {
                item.rare = -1;
            }
            if (item.rare > 6)
            {
                item.rare = 6;
            }
        }