public override void DoAction(IEventArgs args)
        {
            ParaList target = GetTarget(args);
            object   source = GetSource(args);

            if (fields != null && source != null && target != null)
            {
                foreach (FieldPair fN in FieldPair.Parse(fields))
                {
                    string[] ffs = new string[2];
                    ffs[0] = fN.GetFrom();
                    ffs[1] = fN.GetTo();
                    try
                    {
                        FieldInfo    f    = ReflectionCache.GetField(source, ffs[0].Trim());
                        AbstractPara para = null;
                        string       type = f.GetType().Name.ToLower();
                        if ("long".Equals(type))
                        {
                            para = new LongPara(ffs[1].Trim());
                        }
                        if ("int".Equals(type))
                        {
                            para = new IntPara(ffs[1].Trim());
                        }
                        if ("float".Equals(type))
                        {
                            para = new FloatPara(ffs[1].Trim());
                        }
                        if ("double".Equals(type))
                        {
                            para = new DoublePara(ffs[1].Trim());
                        }
                        if ("string".Equals(type))
                        {
                            para = new StringPara(ffs[1].Trim());
                        }
                        if ("boolean".Equals(type))
                        {
                            para = new BoolPara(ffs[1].Trim());
                        }
                        if (para == null)
                        {
                            throw new GameConfigExpception(ffs[1].Trim() + "'s type '" + type + "' is not supported.");
                        }

                        para.SetValue(f.GetValue(source));

                        target.AddPara(para);
                    }
                    catch (Exception e)
                    {
                        throw new GameConfigExpception(fN + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static IPara GetPara(object obj, string field)
        {
            if (obj == null)
            {
                return(null);
            }
            FieldInfo    f    = GetField(obj, field);
            AbstractPara para = null;

            if (f != null)
            {
                string type = f.FieldType.Name;

                if (ParseUtility.IsInt64(type))
                {
                    para = new LongPara(field);
                }
                if (ParseUtility.IsInt32(type))
                {
                    para = new IntPara(field);
                }
                if (ParseUtility.IsSingle(type))
                {
                    para = new FloatPara(field);
                }
                if (ParseUtility.IsDouble(type))
                {
                    para = new DoublePara(field);
                }
                if (ParseUtility.IsString(type))
                {
                    para = new StringPara(field);
                }
                if (ParseUtility.IsBoolean(type))
                {
                    para = new BoolPara(field);
                }
                try
                {
                    if (para != null)
                    {
                        para.SetValue(f.GetValue(obj));
                    }
                }
                catch (Exception e)
                {
                    throw new GameConfigExpception(field + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e));
                }
            }
            return(para);
        }
Ejemplo n.º 3
0
        public static IPara GetPara(object obj, string field)
        {
            if (obj == null)
            {
                return(null);
            }
            FieldInfo    f    = GetField(obj, field);
            AbstractPara para = null;

            if (f != null)
            {
                string type = f.FieldType.Name.ToLower();
                if ("int64".Equals(type))
                {
                    para = new LongPara(field);
                }
                if ("int32".Equals(type))
                {
                    para = new IntPara(field);
                }
                if ("single".Equals(type))
                {
                    para = new FloatPara(field);
                }
                if ("double".Equals(type))
                {
                    para = new DoublePara(field);
                }
                if ("string".Equals(type))
                {
                    para = new StringPara(field);
                }
                if ("boolean".Equals(type))
                {
                    para = new BoolPara(field);
                }
                try
                {
                    if (para != null)
                    {
                        para.SetValue(f.GetValue(obj));
                    }
                }
                catch (Exception e)
                {
                    throw new GameConfigExpception(field + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e));
                }
            }
            return(para);
        }
Ejemplo n.º 4
0
        public override void Effet(ISkillArgs args)
        {
            if (effect != null)
            {
                if (aPara == null)
                {
                    aPara = new BoolPara(Active);
                }

                aPara.SetValue(active);

                args.GetDefault().GetParameters().TempUse(aPara);

                effect.Act(args);

                args.GetDefault().GetParameters().Resume(Active);

                active = !active;
            }
        }