Exemplo n.º 1
0
    /// <summary>
    /// Generates an affixValue based on min and max values, a tier, and a progression function
    /// </summary>
    protected AffixValue GetValueForTier(AffixValue min, AffixValue max, int tier, AffixProgression prog)
    {
        if (!prog.HasProgressionFunction())
        {
            throw new InvalidOperationException("Trying to generate affix value with no or invalid progression function set!");
        }
        // At this point we are sure that the prog function is set, but not if parameters are valid

        var   rng  = new Random();
        float frac = rng.Next(101) / 100.0f;

        // This will raise an exception if parameters are invalid
        AffixValue progressedMin = prog.Apply(min, tier);
        AffixValue progressedMax = prog.Apply(max, tier);

        return(progressedMin + (progressedMax - progressedMin) * frac);
    }
Exemplo n.º 2
0
        private void SaveAffixInfoButton_Click(object sender, EventArgs e)
        {
            AffixProgression newProgression = new AffixProgression(localProgressionFunctionName, localProgressionParameters);

            AffixValueInfo newValueInfo = null;

            if (localValueType == AffixValueType.SingleValue)
            {
                newValueInfo = new AffixValueInfo(localBaseValueMinSingle, localBaseValueMaxSingle, newProgression);
            }
            else if (localValueType == AffixValueType.Range)
            {
                newValueInfo = new AffixValueInfo(localBaseValueMinRange, localBaseValueMaxRange, newProgression);
            }

            AffixInfo newInfo = new AffixInfo(localValueType, localName, newValueInfo, localDescription);

            Serializer.SaveAffixInfoToDisk(newInfo);
            AffixInfo.Register(newInfo);
            currentInfo = newInfo;
            UpdateAllLabels();
        }
Exemplo n.º 3
0
    public AffixValueInfo(AffixValue baseValueMin, AffixValue baseValueMax, AffixProgression[] progressions)
    {
        if (!baseValueMin.IsSameType(baseValueMax))
        {
            throw new ArgumentException($"Mininum and maximum value have to be of the same type!");
        }

        if (BaseValueMin is AffixValueMultiple)
        {
            if ((BaseValueMin as AffixValueMultiple).Count != progressions.Length)
            {
                throw new ArgumentException($"Info AffixValueMultiple needs the same amount of progressions as affix values!", nameof(progressions));
            }
        }

        BaseValueMin = baseValueMin;
        BaseValueMax = baseValueMax;
        Progressions = new AffixProgression[progressions.Length];
        for (int i = 0; i < progressions.Length; i++)
        {
            Progressions[i] = new AffixProgression(progressions[i]);
        }
    }
Exemplo n.º 4
0
 public AffixValueInfo(AffixValue baseValueMin, AffixValue baseValueMax, AffixProgression progression)
     : this(baseValueMin, baseValueMax, new AffixProgression[] { progression })
 {
 }
Exemplo n.º 5
0
 public AffixProgression(AffixProgression src) : this(src.Name, src.Parameters)
 {
 }