Exemple #1
0
        public static MagicalEffect Load(System.IO.BinaryReader reader)
        {
            MagicalEffect effect   = null;
            String        typeName = reader.ReadString();

            Exception innerException = new Exception();

            try
            {
                Type t = Assembly.GetAssembly(typeof(Entity)).GetType(typeName)
                         ?? Scripts.GetType(typeName);
                ConstructorInfo c = t.GetConstructor(new Type[] { typeof(System.IO.BinaryReader) });
                effect = c.Invoke(new object[] { reader }) as MagicalEffect;
            }
            catch (Exception e)
            {
                innerException = e;
            }

            if (effect == null)
            {
                throw new Exception("Magical Effect of type '" + typeName + "' could not be created!", innerException);
            }

            return(effect);
        }
Exemple #2
0
        public static MagicalEffect Create(Entity caster, Entity applicator, SpellInfo spellInfo, double strength)
        {
            MagicalEffect effect         = null;
            Exception     innerException = new Exception();

            try
            {
                Type t = Assembly.GetAssembly(typeof(Entity)).GetType(spellInfo.EffectClassName)
                         ?? Scripts.GetType(spellInfo.EffectClassName);
                ConstructorInfo c = t.GetConstructor(new Type[] { typeof(Entity), typeof(Entity), typeof(SpellInfo), typeof(double) });
                effect = c.Invoke(new object[] { caster, applicator, spellInfo, strength }) as MagicalEffect;
            }
            catch (Exception e)
            {
                innerException = e;
            }

            if (effect == null)
            {
                throw new Exception("Magical Effect of type '" + spellInfo.EffectClassName + "' could not be created!", innerException);
            }

            return(effect);
        }
Exemple #3
0
 protected MagicalEffect CreateEffect(Entity caster, Entity applicator)
 {
     return(MagicalEffect.Create(caster, applicator, Info, Strength));
 }