Beispiel #1
0
 public QA_AttributeModifier(string name, QA_AMModificationType modificationType, float value, QA_AMDuration duration, float lifetime, float modificationInterval, float lifeTimer, float modificationTimer)
 {
     Name                 = name;
     ModificationType     = modificationType;
     Value                = value;
     Duration             = duration;
     Lifetime             = lifetime;
     ModificationInterval = modificationInterval;
     LifeTimer            = lifeTimer;
     ModificationTimer    = modificationTimer;
 }
Beispiel #2
0
 public QA_AttributeModifier(QA_AttributeModifier template)
 {
     Name                 = template.Name;
     ModificationType     = template.ModificationType;
     Value                = template.Value;
     Duration             = template.Duration;
     Lifetime             = template.Lifetime;
     ModificationInterval = template.ModificationInterval;
     LifeTimer            = template.LifeTimer;
     ModificationTimer    = template.ModificationTimer;
 }
        /// <summary>
        /// Removes a modifier from the handler.
        /// </summary>
        /// <param name="name">The name of the modifier.</param>
        /// <param name="duration">The duration of the modifier, used to remove the modifier from the right list.</param>
        public void RemoveModifier(string name, QA_AMDuration duration)
        {
            if (duration == QA_AMDuration.Permanent)
            {
                int modifierCount = PermanentModifiers.Count;
                for (int i = modifierCount - 1; i >= 0; i--)
                {
                    var modifier = PermanentModifiers[i];
                    if (modifier.Name == name)
                    {
                        if (modifier.ModificationType == QA_AMModificationType.RawValue)
                        {
                            SetValue(Value - modifier.Value);
                        }
                        else if (modifier.ModificationType == QA_AMModificationType.Percent)
                        {
                            SetValue(Value - modifier.Value / 100 * MaximumValue);
                        }

                        PermanentModifiers.RemoveAt(i);
                        return;
                    }
                }
            }
            else
            {
                int modifierCount = TemporaryModifiers.Count;
                for (int i = modifierCount - 1; i >= 0; i--)
                {
                    var modifier = TemporaryModifiers[i];
                    if (modifier.Name == name)
                    {
                        if (Mathf.Approximately(modifier.ModificationInterval, 0))
                        {
                            if (modifier.ModificationType == QA_AMModificationType.RawValue)
                            {
                                SetValue(Value - modifier.Value);
                            }
                            else if (modifier.ModificationType == QA_AMModificationType.Percent)
                            {
                                SetValue(Value - modifier.Value / 100 * MaximumValue);
                            }
                        }

                        TemporaryModifiers.RemoveAt(i);
                        return;
                    }
                }
            }
        }