Exemple #1
0
 public static bool animateFloatListObject(
     this MovieClipSnapshot snapshot,
     string id,
     PropertyModifier <List <float> > modifier,
     float delay    = 0,
     float?duration = null,
     PropertyModifier <List <float> > from = null,
     Curve curve = null
     )
 {
     return(snapshot.animateTo <List <float> >(
                id,
                paramName: "progress",
                target: progress => {
         var ret = progress.ToList();
         modifier(ret);
         return ret;
     },
                delay: delay,
                duration: duration,
                from: from != null ? (PropertyProvider <List <float> >)(progress => {
         var ret = progress.ToList();
         from(ret);
         return ret;
     }) : null,
                curve: curve
                ));
 }
Exemple #2
0
 public void AddModifier(PropertyModifier modifier)
 {
     modifier.StackChanged += OnModifierStackChanged;
     Modifiers.Add(modifier);
     Modifiers = Modifiers.OrderBy(m => m.Type).ToList();
     OnChange();
 }
Exemple #3
0
        private string PropertyModifierValueString(PropertyModifier modifier, bool absolute = false)
        {
            modifier.Entity = modifier.Entity ?? CharacterManager.Instance.Character.Entity;
            modifier.ChangeStack(StackCount);

            var property = modifier.Entity.GetComponent <PropertiesComponent>().Get(modifier.Property.Id);
            var contains = property.Modifiers.Contains(modifier);

            if (contains)
            {
                property.Modifiers.Remove(modifier);
            }

            var value = property.Value();
            var delta = modifier.Modify(value) - value;

            delta = absolute ? Mathf.Abs(delta) : delta;

            if (contains)
            {
                property.Modifiers.Add(modifier);
            }

            return(Property.ValueString(modifier.Property.Type, delta));
        }
Exemple #4
0
    private void ProcessBuffs()
    {
        Color avatarColor = GameDefines.defaultAvatarColor;

        foreach (var kvp in bufDct)
        {
            ClientServerCommon.Buff buffCfg = ConfigDatabase.DefaultCfg.ActionConfig.GetBuffById(kvp.Value.bufID);
            if (buffCfg == null)
            {
                continue;
            }

            for (int modifierSetIdx = 0; modifierSetIdx < buffCfg.modifierSets.Count; ++modifierSetIdx)
            {
                ClientServerCommon.PropertyModifierSet modifierSetCfg = buffCfg.modifierSets[modifierSetIdx];

                for (int idx = 0; idx < modifierSetCfg.modifiers.Count; ++idx)
                {
                    PropertyModifier modifier = modifierSetCfg.modifiers[idx];
                    if (modifier.type != PropertyModifier._Type.ColorModifier)
                    {
                        continue;
                    }
                    avatarColor = new UnityEngine.Color(modifier.color.r, modifier.color.g, modifier.color.b, modifier.color.a);
                }
            }
        }

        avatar.SetColor(avatarColor);
    }
Exemple #5
0
    private void PropertyReset(PropertyModifier propertyModifier)
    {
        switch (propertyModifier)
        {
        case PropertyModifier.Damage:
            projectileDamageMultiplier = 1;
            break;

        case PropertyModifier.FireRate:
            fireRateMultiplier = 1;
            break;

        case PropertyModifier.AOE:
            projectileAOEMultiplier = 1;
            break;

        case PropertyModifier.Range:
            rangeMultiplier = 1;
            break;

        case PropertyModifier.ProjectileSpeed:
            projectileSpeedMultiplier = 1;
            break;
        }
        OnPropertyReset?.Invoke(propertyModifier);
        RemoveParticlesForModifier(propertyModifier);
    }
Exemple #6
0
 public static string AsString(this PropertyModifier modifier)
 {
     if (modifier == PropertyModifier.None)
     {
         return(string.Empty);
     }
     return(EnumToLower(modifier));
 }
Exemple #7
0
        public void RemoveModifier(PropertyModifier modifier)
        {
            var fraction = this.health.HealthFraction;

            Get(modifier.Property.Type).RemoveModifier(modifier);

            this.health.Health = this.health.HealthMax * fraction;
        }
Exemple #8
0
 private void RemoveParticlesForModifier(PropertyModifier propertyModifier)
 {
     activeModifiers.Remove(propertyModifier);
     foreach (GameObject particle in particles[propertyModifier])
     {
         OnParticleEnded(particle);
     }
 }
Exemple #9
0
        public void ApplyModifier(PropertyModifier modifier)
        {
            var fraction = this.health.HealthFraction;

            modifier.Entity = gameObject;
            Get(modifier.Property.Type).AddModifier(modifier);

            this.health.Health = this.health.HealthMax * fraction;
        }
Exemple #10
0
        private string PropertyModifierValueString(PropertyModifier modifier, bool absolute = false)
        {
            modifier.Entity = modifier.Entity ?? CharacterManager.Instance.Character.Entity;

            var value = modifier.Modify(0);

            value = absolute ? Mathf.Abs(value) : value;

            return(Property.ValueString(modifier.Property.Type, value));
        }
        public static PropertyGenerator Property(AccessModifier scope, PropertyModifier modifier, Type returnType, string name, bool hasDefault)
        {
            var prop = new PropertyGenerator();

            prop.scope      = scope;
            prop.modifier   = modifier;
            prop.name       = name;
            prop.returnType = returnType;
            return(prop);
        }
Exemple #12
0
        private static string ApplyModifier(PropertyModifier modifier, string input)
        {
            switch (modifier)
            {
            case PropertyModifier.None: return(input);

            case PropertyModifier.Lower: return(input.ToLowerInvariant());

            default:
                throw new NotSupportedException($"Don't know how to apply modifier {modifier} to '{input}'");
            }
        }
Exemple #13
0
        public static PropertyGenerator Property(AccessModifier scope, PropertyModifier modifier, string returnType, string name, bool hasDefault, bool isPrimitive, bool isValueType)
        {
            var prop = new PropertyGenerator();

            prop.scope              = scope;
            prop.modifier           = modifier;
            prop.name               = name;
            prop.returnTypeString   = returnType;
            prop.returnTypeIsString = true;
            prop.stringIsPrimitive  = isPrimitive;
            prop.stringIsValueType  = isValueType;
            return(prop);
        }
        public static PropertyGenerator Property(AccessModifier scope, PropertyModifier modifier, string assemblyQualifiedReturnType, string name, bool hasDefault, bool isPrimitive, bool isValueType)
        {
            var prop = new PropertyGenerator();

            prop.scope    = scope;
            prop.modifier = modifier;
            prop.name     = name;
            prop.assemblyQualifiedReturnType    = assemblyQualifiedReturnType;
            prop.useAssemblyQualifiedReturnType = true;
            prop.assemblyQualifiedIsPrimitive   = isPrimitive;
            prop.assemblyQualifiedIsValueType   = isValueType;
            return(prop);
        }
Exemple #15
0
        private static string ExtractNameAndModifier(string rawInput, out PropertyModifier modifier)
        {
            string[] chunks = rawInput.Split(s_modifierNameSplitter);

            if (chunks.Length < 2)
            {
                modifier = PropertyModifier.None;
                return(rawInput);
            }
            else if (chunks.Length == 2)
            {
                modifier = (PropertyModifier)Enum.Parse(typeof(PropertyModifier), chunks[0], true);
                return(chunks[1]);
            }
            else
            {
                throw new NotSupportedException($"{chunks.Length - 1} modifiers were found in '{rawInput}', only one is supported.");
            }
        }
Exemple #16
0
        public IFieldModifier[] GetFields()
        {
            FieldInfo[]      fields     = this.GetFieldInfos();
            PropertyInfo[]   properties = this.GetPropertyInfos();
            IFieldModifier[] result     = new IFieldModifier[fields.Length + properties.Length];
            int i = 0;

            for (; i < fields.Length; ++i)
            {
                result[i] = new FieldModifier(fields[i]);
            }

            for (int j = 0; j < properties.Length; ++j, ++i)
            {
                result[i] = new PropertyModifier(properties[j]);
            }

            return(result);
        }
Exemple #17
0
        public Attribute(AttributeData data, IPropertyRepository propertyRepository)
        {
            Id          = data.Id;
            Index       = data.Index;
            Type        = data.Type;
            Name        = I18N.Instance.Get(data.NameKey);
            Description = I18N.Instance.Get(data.DescriptionKey);
            Icon        = data.Icon;
            IsPrimary   = data.IsPrimary;

            foreach (var propertyModifierData in data.PropertyModifiers)
            {
                var modifier = new PropertyModifier(
                    propertyRepository.Find(propertyModifierData.PropertyId),
                    propertyModifierData
                    );

                this.propertyModifiers.Add(modifier);
            }
        }
Exemple #18
0
        public ModifyStatsBehaviour(ModifyStatsBehaviourData data,
                                    IAttributeRepository attributeRepository, IPropertyRepository propertyRepository,
                                    List <Validator> validators) : base(data, validators)
        {
            foreach (var attributeModifierData in data.AttributeModifiers)
            {
                var modifier = new AttributeModifier(
                    attributeRepository.Find(attributeModifierData.AttributeId),
                    attributeModifierData
                    );

                this.attributeModifiers.Add(modifier);
            }

            foreach (var propertyModifierData in data.PropertyModifiers)
            {
                var modifier = new PropertyModifier(
                    propertyRepository.Find(propertyModifierData.PropertyId),
                    propertyModifierData
                    );

                this.propertyModifiers.Add(modifier);
            }
        }
Exemple #19
0
 public void RemoveModifier(PropertyModifier <List <ActivatedAbility> > modifier)
 {
     _abilities.RemoveModifier(modifier);
 }
Exemple #20
0
 public void AddModifier(PropertyModifier <List <ActivatedAbility> > modifier)
 {
     _abilities.AddModifier(modifier);
 }
Exemple #21
0
        private void    CopyObject(StringBuilder buffer, object instance, string prefix)
        {
            if (instance != null)
            {
                Type     type = instance.GetType();
                object[] actions;

                if (this.typeDrawers.TryGetValue(type, out actions) == true)
                {
                    buffer.AppendLine((actions[1] as Func <object, string, string>)(instance, prefix));
                }
                else
                {
                    if (instance.GetType().IsArray == true)
                    {
                        IEnumerable array = instance as IEnumerable;

                        foreach (object element in array)
                        {
                            this.CopyObject(buffer, element, "  ");
                        }
                    }
                    else if (type != typeof(string) &&
                             (type.IsClass == true || type.IsStruct() == true))
                    {
                        ClassDefinition classDefinition;

                        if (this.refMembers.TryGetValue(type, out classDefinition) == false)
                        {
                            int              j          = 0;
                            FieldInfo[]      fields     = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
                            PropertyInfo[]   properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                            IFieldModifier[] members    = new IFieldModifier[fields.Length + properties.Length];

                            for (int i = 0; i < fields.Length; i++, ++j)
                            {
                                members[j] = new FieldModifier(fields[i]);
                            }

                            for (int i = 0; i < properties.Length; i++, ++j)
                            {
                                members[j] = new PropertyModifier(properties[i]);
                            }

                            classDefinition = new ClassDefinition(members);

                            this.refMembers.Add(type, classDefinition);
                        }

                        for (int i = 0; i < classDefinition.members.Length; i++)
                        {
                            this.CopyObject(buffer, classDefinition.members[i].GetValue(instance), "  " + classDefinition.nicifiedNames[i] + " : ");
                        }
                    }
                    else
                    {
                        buffer.AppendLine(prefix + instance.ToString());
                    }
                }
            }
            else
            {
                buffer.AppendLine(prefix + "NULL");
            }
        }
Exemple #22
0
 public void RemoveModifier(PropertyModifier modifier)
 {
     modifier.StackChanged -= OnModifierStackChanged;
     Modifiers.Remove(modifier);
     OnChange();
 }
Exemple #23
0
 public void AddPowerModifier(PropertyModifier<int?> modifier)
 {
     _power.AddModifier(modifier);
 }
Exemple #24
0
 public void AddToughnessModifier(PropertyModifier<int?> modifier)
 {
     _toughness.AddModifier(modifier);
 }
Exemple #25
0
 public void AddModifier(PropertyModifier <List <StaticAbility> > modifier)
 {
     _abilities.AddModifier(modifier);
 }
Exemple #26
0
 public void RemovePowerModifier(PropertyModifier <int?> modifier)
 {
     _power.RemoveModifier(modifier);
 }
Exemple #27
0
 public void RemoveToughnessModifier(PropertyModifier <int?> modifier)
 {
     _toughness.RemoveModifier(modifier);
 }
Exemple #28
0
 public void AddToughnessModifier(PropertyModifier <int?> modifier)
 {
     _toughness.AddModifier(modifier);
 }
Exemple #29
0
 public void AddPowerModifier(PropertyModifier <int?> modifier)
 {
     _power.AddModifier(modifier);
 }
Exemple #30
0
 public void RemoveModifier(PropertyModifier <List <StaticAbility> > modifier)
 {
     _abilities.RemoveModifier(modifier);
 }
Exemple #31
0
 public void AddModifier(PropertyModifier <List <TriggeredAbility> > modifier)
 {
     _abilities.AddModifier(modifier);
 }
Exemple #32
0
 public void RemovePowerModifier(PropertyModifier<int?> modifier)
 {
     _power.RemoveModifier(modifier);
 }
Exemple #33
0
 public void RemoveModifier(PropertyModifier <List <TriggeredAbility> > modifier)
 {
     _abilities.RemoveModifier(modifier);
 }
Exemple #34
0
 public void RemoveToughnessModifier(PropertyModifier<int?> modifier)
 {
     _toughness.RemoveModifier(modifier);
 }