Beispiel #1
0
        public override void DoAction(IEventArgs args)
        {
            int from = FreeUtil.ReplaceInt(this.from, args);
            int to   = FreeUtil.ReplaceInt(this.to, args);

            if (StringUtil.IsNullOrEmpty(i))
            {
                i = "i";
            }
            if (from > to)
            {
                for (int i = from; i >= to; i--)
                {
                    args.GetDefault().GetParameters().TempUse(new IntPara(this.i, i));
                    action.Act(args);
                    args.GetDefault().GetParameters().Resume(this.i);
                }
            }
            else
            {
                for (int i = from; i <= to; i++)
                {
                    args.GetDefault().GetParameters().TempUse(new IntPara(this.i, i));
                    action.Act(args);
                    args.GetDefault().GetParameters().Resume(this.i);
                }
            }
        }
Beispiel #2
0
        public static void HandleMoveAction(ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, IEventArgs args, bool remove)
        {
            args.TempUse(PARA_ITEM, ip);
            args.GetDefault().GetParameters().TempUse(new StringPara(PARA_ITEM_MOVE_FROM, fromIn.GetName()));
            args.GetDefault().GetParameters().TempUse(new StringPara(PARA_ITEM_MOVE_TO, toIn.GetName()));
            if (remove)
            {
                if (fromUI.MoveAction != null)
                {
                    fromUI.MoveAction.Act(args);
                }
            }
            else
            {
                if (toUI != fromUI)
                {
                    if (toUI.MoveAction != null)
                    {
                        toUI.MoveAction.Act(args);
                    }
                }
            }

            args.Resume(PARA_ITEM);
            args.GetDefault().GetParameters().Resume(PARA_ITEM_MOVE_FROM);
            args.GetDefault().GetParameters().Resume(PARA_ITEM_MOVE_TO);
        }
Beispiel #3
0
        private void SetArg(FuncArg arg, IList <ArgValue> funcArgs, IEventArgs args)
        {
            ArgValue fa = GetArgValue(arg, funcArgs, args);

            if (fa != null)
            {
                IPara para = ParaUtil.GetPara(arg.GetType());
                if (para != null)
                {
                    try
                    {
                        IPara old = new ParaExp(fa.GetValue()).GetSourcePara(args);
                        if (old != null)
                        {
                            if (old.GetValue() != null)
                            {
                                para = para.Initial("=", old.GetValue().ToString());
                            }
                            else
                            {
                                para = para.Initial("=", string.Empty);
                            }
                        }
                        else
                        {
                            para = para.Initial("=", FreeUtil.ReplaceNumber(fa.GetValue(), args));
                        }
                    }
                    catch (Exception)
                    {
                        para = para.Initial("=", FreeUtil.ReplaceNumber(fa.GetValue(), args));
                    }
                    para.SetName("arg_" + arg.GetName());
                    args.GetDefault().GetParameters().TempUse(para);
                    IPara p = (IPara)para.Borrow();
                    p.SetName(arg.GetName());
                    if (para.GetValue() != null)
                    {
                        p.SetValue("=", para);
                    }
                    args.GetDefault().GetParameters().TempUse(p);
                    FreeLog.FuncArg(p.ToString());
                }
                else
                {
                    // 非简单变量
                    ((BaseEventArgs)args).TempUse(arg.GetName(), args.GetUnit(fa.GetValue()));
                }
            }
        }
        public override void DoAction(IEventArgs args)
        {
            int random  = RandomUtil.Random(0, 100);
            int percent = FreeUtil.ReplaceInt(this.percent, args);

            if (random <= percent)
            {
                args.GetDefault().GetParameters().TempUse(new IntPara("roll", random));
                if (action != null)
                {
                    action.Act(args);
                }
                args.GetDefault().GetParameters().Resume("roll");
            }
        }
Beispiel #5
0
        public override void DoAction(IEventArgs args)
        {
            if (StringUtil.IsNullOrEmpty(key))
            {
                key = BaseEventArgs.DEFAULT;
            }
            IParable unit = args.GetUnit(key);

            if (unit != null)
            {
                IPara sort = unit.GetParameters().Get(sorter);
                if (sort != null)
                {
                    ParaListSet pls = (ParaListSet)sort;
                    if (action != null)
                    {
                        Iterator <ParaList> it = pls.Iterator();
                        int i = 1;
                        while (it.HasNext())
                        {
                            ParaList pl = it.Next();
                            args.TempUse("element", new SimpleParable(pl));
                            args.GetDefault().GetParameters().TempUse(new IntPara("index", i++));
                            if (condition == null || condition.Meet(args))
                            {
                                if (action != null)
                                {
                                    action.Act(args);
                                }
                                if (FreeUtil.ReplaceBool(remove, args))
                                {
                                    it.Remove();
                                }
                            }
                            args.GetDefault().GetParameters().Resume("index");
                            args.Resume("element");
                        }
                        if (i == 1)
                        {
                            if (noneAction != null)
                            {
                                noneAction.Act(args);
                            }
                        }
                    }
                }
            }
        }
Beispiel #6
0
 public override void DoAction(IEventArgs args)
 {
     if (paras == null)
     {
         paras = new List <ParaValue>();
     }
     foreach (ParaValue pv in paras)
     {
         args.GetDefault().GetParameters().TempUse(pv.GetPara(args));
     }
     action.Act(args);
     foreach (ParaValue pv_1 in paras)
     {
         args.GetDefault().GetParameters().Resume(pv_1.GetName());
     }
 }
Beispiel #7
0
        public override void DoAction(IEventArgs args)
        {
            IParable p = null;

            if (StringUtil.IsNullOrEmpty(key))
            {
                p = args.GetDefault();
            }
            else
            {
                p = args.GetUnit(key);
            }
            if (p != null && paras != null)
            {
                foreach (ParaValue para in paras)
                {
                    if (null == para)
                    {
                        throw new GameConfigExpception("para is not a null field at " + key);
                    }
                    if (!p.GetParameters().HasPara(para.GetName()) || @override)
                    {
                        p.GetParameters().AddPara(para.GetPara(args));
                    }
                }
            }
            if (paras == null || paras.Count == 0)
            {
                _logger.Info("AddParaValueAction paras is null or count is 0 !");
            }
        }
Beispiel #8
0
        public override void DoAction(IEventArgs args)
        {
            IParable p = null;

            if (StringUtil.IsNullOrEmpty(key))
            {
                p = args.GetDefault();
            }
            else
            {
                p = args.GetUnit(key);
            }
            if (p != null && paras != null)
            {
                foreach (IPara para in paras)
                {
                    if (!p.GetParameters().HasPara(para) || @override)
                    {
                        IPara clone = (IPara)para.Copy();
                        clone.SetName(FreeUtil.ReplaceVar(clone.GetName(), args));
                        p.GetParameters().AddPara(clone);
                    }
                }
            }
        }
Beispiel #9
0
 public override void DoAction(IEventArgs args)
 {
     if (this.args != null)
     {
         foreach (ArgValue av in this.args)
         {
             ParaValue pv = new ParaValue();
             pv.SetName(av.GetName());
             pv.SetValue(av.GetValue());
             IPara para = args.GetDefault().GetParameters().Get(av.GetName());
             if (para != null)
             {
                 if (para is IntPara)
                 {
                     pv.SetType("int");
                 }
                 if (para is StringPara)
                 {
                     pv.SetType("string");
                 }
                 if (para is BoolPara)
                 {
                     pv.SetType("bool");
                 }
                 if (para is FloatPara)
                 {
                     pv.SetType("float");
                 }
                 if (para is DoublePara)
                 {
                     pv.SetType("double");
                 }
             }
             // 如果为空,则说明在父规则中定义了当前规则的组件,所以忽略当前设置,直接使用父规则中的设置
             // 如 bioPushcar引用了 bioComponent, reliveComponent,
             // bioComponent中也引用了reliveComponent,当bioComponent设置组件值时,reliveComponent还未初始化
             // 则bioPushcar中的reliveComponent将在最后赋值,也是最终的值
             IPara paraValue = pv.GetPara(args);
             if (paraValue != null)
             {
                 args.GetDefault().GetParameters().AddPara(paraValue);
             }
         }
     }
 }
Beispiel #10
0
        private void SetOne(IEventArgs args, string field, int value)
        {
            IntPara para = (IntPara)args.GetDefault().GetParameters().Get(field);

            if (para != null)
            {
                para.SetValue(value);
            }
        }
 public override void DoAction(IEventArgs args)
 {
     if (this.args != null)
     {
         foreach (ParaValue pv in this.args)
         {
             args.GetDefault().GetParameters().AddPara(pv.GetPara(args));
         }
     }
 }
Beispiel #12
0
 private void RemoveArg(FuncArg fa, IEventArgs args)
 {
     if (fa != null)
     {
         string t = fa.GetType();
         if ("string".Equals(t) || "int".Equals(t) || "bool".Equals(t) || "float".Equals(t) || "long".Equals(t) || "double".Equals(t))
         {
             IPara p = args.GetDefault().GetParameters().Get("arg_" + fa.GetName());
             p.Recycle();
             p = args.GetDefault().GetParameters().Get(fa.GetName());
             p.Recycle();
             args.GetDefault().GetParameters().Resume("arg_" + fa.GetName());
             args.GetDefault().GetParameters().Resume(fa.GetName());
         }
         else
         {
             ((BaseEventArgs)args).Resume(fa.GetName());
         }
     }
 }
 private void HandleOne(int all, int index, string k, string v, IEventArgs args)
 {
     args.GetDefault().GetParameters().TempUse(new IntPara("index", index));
     args.GetDefault().GetParameters().TempUse(new IntPara("count", all));
     args.GetDefault().GetParameters().TempUse(new StringPara("key", k));
     args.GetDefault().GetParameters().TempUse(new StringPara("value", v));
     if (action != null)
     {
         action.Act(args);
     }
     args.GetDefault().GetParameters().Resume("count");
     args.GetDefault().GetParameters().Resume("index");
     args.GetDefault().GetParameters().Resume("key");
     args.GetDefault().GetParameters().Resume("value");
 }
Beispiel #14
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;
            IGameUnit         player = GetPlayer(args);

            if (player != null)
            {
                FreeData fd = (FreeData)player;
                try
                {
                    ItemPosition currentItem = fd.freeInventory.GetCurrentItem();
                    if (!StringUtil.IsNullOrEmpty(cat))
                    {
                        currentItem = fd.freeInventory.GetCurrentItem(FreeUtil.ReplaceVar(cat, args));
                    }
                    if (currentItem != null)
                    {
                        currentItem.GetInventory().RemoveItem(fr, currentItem);
                        if (drop != null)
                        {
                            fr.TempUse("item", currentItem.GetKey());
                            drop.Act(args);
                            fr.Resume("item");
                        }
                    }
                }
                catch (Exception e)
                {
                    StringPara sp = new StringPara("message", e.Message);
                    args.GetDefault().GetParameters().TempUse(sp);
                    if (message != null)
                    {
                        message.Act(args);
                    }
                    args.GetDefault().GetParameters().Resume("message");
                }
            }
        }
 public override void DoAction(IEventArgs args)
 {
     if (paras == null)
     {
         paras = new List <ParaValue>();
     }
     foreach (ParaValue pv in paras)
     {
         args.GetDefault().GetParameters().TempUse(pv.GetPara(args));
     }
     try
     {
         action.Act(args);
     }
     catch (Exception e)
     {
         _logger.Error("DefineParaAction action failed " + e.Message);
     }
     foreach (ParaValue pv_1 in paras)
     {
         args.GetDefault().GetParameters().Resume(pv_1.GetName());
     }
 }
Beispiel #16
0
        public override void DoAction(IEventArgs args)
        {
            ParaList list = args.GetDefault().GetParameters();

            if (list.HasPara("resetpos"))
            {
                resetpos = (int)list.Get("resetpos").GetValue();
                var poss = args.FreeContext.Poss;
                if (!poss.ExsitIndex(TYPE, resetpos))
                {
                    poss.Remove(TYPE, resetpos);
                }
            }
        }
 public override void DoAction(IEventArgs args)
 {
     if (cache == null || keys.Contains("{") || keys.Contains("}"))
     {
         cache = new LinkedHashMap <string, string>();
         string[] ks = StringUtil.Split(FreeUtil.ReplaceVar(keys, args), new string[] { ",", "," });
         foreach (string k in ks)
         {
             string[] vs = StringUtil.Split(k, "=");
             if (vs.Length == 2)
             {
                 cache[vs[0].Trim()] = vs[1].Trim();
             }
             else
             {
                 if (vs.Length == 1)
                 {
                     cache[vs[0].Trim()] = vs[0].Trim();
                 }
             }
         }
     }
     if (StringUtil.IsNullOrEmpty(key))
     {
         int i = 0;
         foreach (string k in cache.Keys)
         {
             HandleOne(cache.Count, i + 1, k, cache[k], args);
             i++;
         }
     }
     else
     {
         string k = FreeUtil.ReplaceVar(key, args);
         if (cache.ContainsKey(k) || useKey)
         {
             string v = cache[k];
             args.GetDefault().GetParameters().TempUse(new BoolPara("hasKey", v != null));
             if (v == null)
             {
                 v = key;
             }
             args.GetDefault().GetParameters().TempUse(new StringPara("key", k));
             args.GetDefault().GetParameters().TempUse(new StringPara("value", v));
             if (action != null)
             {
                 action.Act(args);
             }
             args.GetDefault().GetParameters().Resume("key");
             args.GetDefault().GetParameters().Resume("value");
             args.GetDefault().GetParameters().Resume("hasKey");
         }
     }
 }
Beispiel #18
0
        public override void DoAction(IEventArgs args)
        {
            IParable p = null;

            if (StringUtil.IsNullOrEmpty(key))
            {
                p = args.GetDefault();
            }
            else
            {
                p = args.GetUnit(key);
            }
            if (p != null && para != null)
            {
                foreach (string pa in StringUtil.Split(para, ","))
                {
                    p.GetParameters().RemovePara(pa.Trim());
                }
            }
        }
Beispiel #19
0
 private void HandleArmor(IEventArgs args)
 {
     if ("ReduceDamage" == code)
     {
         FreeData fd = (FreeData)args.GetUnit("target");
         if (fd != null)
         {
             SimpleParable sp = (SimpleParable)args.GetUnit("damage");
             if (sp != null)
             {
                 PlayerDamageInfo info = (PlayerDamageInfo)((ObjectFields)((SimpleParaList)sp.GetParameters()).GetFieldList()[0]).GetObj();
                 float            da   = ReduceDamageUtil.HandleDamage(args, fd, info);
                 FloatPara        d    = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                 if (d != null)
                 {
                     d.SetValue(da);
                 }
             }
         }
     }
 }
Beispiel #20
0
        public override void DoAction(IEventArgs args)
        {
            if (count == 0)
            {
                count = 1;
            }
            UnitPosition[] ups = null;
            if (count == 1)
            {
                UnitPosition sub = pos.Select(args);
                if (sub == null)
                {
                    throw new GameActionExpception("找不到pos点[" + pos.ToString() + "]");
                }

                ups = new UnitPosition[] { sub };
            }
            else
            {
                ups = pos.Select(args, count);
            }
            int index = 0;

            foreach (UnitPosition up in ups)
            {
                args.GetDefault().GetParameters().TempUse(new FloatPara("x", up.GetX()));
                args.GetDefault().GetParameters().TempUse(new FloatPara("y", up.GetY()));
                args.GetDefault().GetParameters().TempUse(new FloatPara("z", up.GetZ()));
                args.GetDefault().GetParameters().TempUse(new IntPara("index", ++index));
                action.Act(args);
                args.GetDefault().GetParameters().Resume("x");
                args.GetDefault().GetParameters().Resume("y");
                args.GetDefault().GetParameters().Resume("z");
                args.GetDefault().GetParameters().Resume("index");
            }
        }
Beispiel #21
0
        public override void DoAction(IEventArgs args)
        {
            List <DataRecord> records = GetRecords();

            foreach (DataRecord record in records)
            {
                args.GetDefault().GetParameters().TempUse(new FloatPara("x", float.Parse(record.GetValue("x"))));
                args.GetDefault().GetParameters().TempUse(new FloatPara("y", float.Parse(record.GetValue("y"))));
                args.GetDefault().GetParameters().TempUse(new FloatPara("z", float.Parse(record.GetValue("z"))));
                args.GetDefault().GetParameters().TempUse(new FloatPara("rotation", float.Parse(record.GetValue("rotation"))));
                try
                {
                    action.Act(args);
                }
                catch
                {
                    Logger.DebugFormat("SqlPointAction has no action !");
                }
                args.GetDefault().GetParameters().Resume("x");
                args.GetDefault().GetParameters().Resume("y");
                args.GetDefault().GetParameters().Resume("z");
                args.GetDefault().GetParameters().Resume("rotation");
            }
        }
Beispiel #22
0
        public override void DoAction(IEventArgs args)
        {
            IParable p = null;

            if (StringUtil.IsNullOrEmpty(key))
            {
                p = args.GetDefault();
            }
            else
            {
                p = args.GetUnit(key);
            }
            if (p != null && paras != null)
            {
                foreach (ParaValue para in paras)
                {
                    if (!p.GetParameters().HasPara(para.GetName()) || @override)
                    {
                        p.GetParameters().AddPara(para.GetPara(args));
                    }
                }
            }
        }
Beispiel #23
0
        private void ReduceDamage(IEventArgs args, PlayerEntity player)
        {
            SimpleParable sp = (SimpleParable)args.GetUnit("damage");

            if (sp != null)
            {
                PlayerDamageInfo damage = (PlayerDamageInfo)sp.GetFieldObject(0);
                float            da     = damage.damage;
                if (damage.part == (int)EBodyPart.Head)
                {
                    int helId = player.gamePlay.HelmetLv;
                    if (armorDic.ContainsKey(helId))
                    {
                        ArmorData ad = armorDic[helId];

                        da = ReduceDamage(args, player, damage, ad.reduce, false);
                    }
                }
                else if (damage.part == (int)EBodyPart.Chest || damage.part == (int)EBodyPart.Stomach || damage.part == (int)EBodyPart.Pelvis)
                {
                    int armor = player.gamePlay.ArmorLv;
                    if (armorDic.ContainsKey(armor))
                    {
                        ArmorData ad = armorDic[armor];

                        da = ReduceDamage(args, player, damage, ad.reduce, true);
                    }
                }

                FloatPara d = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                if (d != null)
                {
                    d.SetValue(da);
                }
            }
        }
Beispiel #24
0
 private void HandleOne(int all, int index, string[] ks, IEventArgs args)
 {
     args.GetDefault().GetParameters().TempUse(new IntPara("index", index));
     args.GetDefault().GetParameters().TempUse(new IntPara("count", all));
     for (int i = 0; i < ks.Length; i++)
     {
         args.GetDefault().GetParameters().TempUse(new StringPara("r" + (i + 1), ks[i].Trim()));
     }
     if (action != null)
     {
         action.Act(args);
     }
     args.GetDefault().GetParameters().Resume("count");
     args.GetDefault().GetParameters().Resume("index");
     for (int i_1 = 0; i_1 < ks.Length; i_1++)
     {
         args.GetDefault().GetParameters().Resume("r" + (i_1 + 1));
     }
 }
Beispiel #25
0
        public override void DoAction(IEventArgs args)
        {
            Vector3 fromV = UnityPositionUtil.ToVector3(from.Select(args));
            Vector3 toV   = UnityPositionUtil.ToVector3(to.Select(args));

            Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z));

            RaycastHit hitInfo;
            bool       hited = Physics.Raycast(r, out hitInfo);

            if (type == (int)TraceType.Water)
            {
                float sur = SingletonManager.Get <MapConfigManager>().DistanceAboveWater(fromV);
                if (sur > 0)
                {
                    hitInfo.point = new Vector3(fromV.x, fromV.y - sur, fromV.z);
                    hited         = true;
                }
            }

            args.GetDefault().GetParameters().TempUse(new FloatPara("fx", fromV.x));
            args.GetDefault().GetParameters().TempUse(new FloatPara("fy", fromV.y));
            args.GetDefault().GetParameters().TempUse(new FloatPara("fz", fromV.z));
            args.GetDefault().GetParameters().TempUse(new FloatPara("tx", toV.x));
            args.GetDefault().GetParameters().TempUse(new FloatPara("ty", toV.y));
            args.GetDefault().GetParameters().TempUse(new FloatPara("tz", toV.z));

            if (hited)
            {
                args.GetDefault().GetParameters().TempUse(new FloatPara("x", hitInfo.point.x));
                args.GetDefault().GetParameters().TempUse(new FloatPara("y", hitInfo.point.y));
                args.GetDefault().GetParameters().TempUse(new FloatPara("z", hitInfo.point.z));

                if (action != null)
                {
                    action.Act(args);
                }

                args.GetDefault().GetParameters().Resume("x");
                args.GetDefault().GetParameters().Resume("y");
                args.GetDefault().GetParameters().Resume("z");
            }
            else
            {
                if (noHitAction != null)
                {
                    noHitAction.Act(args);
                }
            }

            args.GetDefault().GetParameters().Resume("fx");
            args.GetDefault().GetParameters().Resume("fy");
            args.GetDefault().GetParameters().Resume("fz");
            args.GetDefault().GetParameters().Resume("tx");
            args.GetDefault().GetParameters().Resume("ty");
            args.GetDefault().GetParameters().Resume("tz");
        }
Beispiel #26
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity playerEntity = GetPlayerEntity(args);

            if (playerEntity != null)
            {
                SimpleParable sp = (SimpleParable)args.GetUnit("damage");
                if (sp != null)
                {
                    FloatPara        d      = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                    PlayerDamageInfo damage = (PlayerDamageInfo)sp.GetFieldObject(0);

                    if (damage.type != (int)EUIDeadType.Weapon && damage.type != (int)EUIDeadType.Unarmed)
                    {
                        return;
                    }

                    if (playerEntity.gamePlay.CurHelmet > 0)
                    {
                        var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.HelmetLv);
                        if (config != null)
                        {
                            if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part))
                            {
                                float readDamage = damage.damage;
                                float reduce     = readDamage * config.NewWeaponCfg.DamageReduction / 100;
                                reduce = Math.Min(playerEntity.gamePlay.CurHelmet, reduce);
                                playerEntity.gamePlay.CurHelmet = Math.Max(0, playerEntity.gamePlay.CurHelmet - (int)readDamage);
                                if (reduce > 0 && playerEntity.gamePlay.CurHelmet == 0)
                                {
                                    playerEntity.gamePlay.HelmetLv = playerEntity.gamePlay.MaxHelmet = 0;
                                    SimpleProto msg = FreePool.Allocate();
                                    msg.Key = FreeMessageConstant.ChickenTip;
                                    msg.Ss.Add("word75," + config.NewWeaponCfg.Name);
                                    FreeMessageSender.SendMessage(playerEntity, msg);
                                }

                                damage.damage -= reduce;
                                playerEntity.statisticsData.Statistics.DefenseDamage += reduce;

                                d.SetValue(damage.damage);
                            }
                        }
                    }

                    if (playerEntity.gamePlay.CurArmor > 0)
                    {
                        var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.ArmorLv);
                        if (config != null)
                        {
                            if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part))
                            {
                                float readDamage = damage.damage;
                                float reduce     = readDamage * config.NewWeaponCfg.DamageReduction / 100;
                                reduce = Math.Min(playerEntity.gamePlay.CurArmor, reduce);
                                playerEntity.gamePlay.CurArmor = Math.Max(0, playerEntity.gamePlay.CurArmor - (int)readDamage);
                                if (reduce > 0 && playerEntity.gamePlay.CurArmor == 0)
                                {
                                    playerEntity.gamePlay.ArmorLv = playerEntity.gamePlay.MaxArmor = 0;
                                    SimpleProto msg = FreePool.Allocate();
                                    msg.Key = FreeMessageConstant.ChickenTip;
                                    msg.Ss.Add("word75," + config.NewWeaponCfg.Name);
                                    FreeMessageSender.SendMessage(playerEntity, msg);
                                }

                                damage.damage -= reduce;
                                playerEntity.statisticsData.Statistics.DefenseDamage += reduce;

                                d.SetValue(damage.damage);
                            }
                        }
                    }
                }
            }
        }
        public override void DoAction(IEventArgs args)
        {
            object target = GetTarget(args);

            if (fields != null && values != null)
            {
                string[] fs = StringUtil.Split(fields, ",");
                string[] vs = StringUtil.Split(values, ",");
                if (fs.Length == vs.Length)
                {
                    for (int i = 0; i < fs.Length; i++)
                    {
                        try
                        {
                            string    fName = fs[i].Trim();
                            FieldInfo f     = ReflectionCache.GetField(target, fName);
                            string    type  = f.GetType().Name.ToLower();
                            IPara     p     = null;
                            string[]  ss    = StringUtil.Split(vs[i].Trim(), ".");
                            if (ss.Length == 2)
                            {
                                if (args.GetUnit(ss[0].Trim()) != null)
                                {
                                    p = args.GetUnit(ss[0].Trim()).GetParameters().Get(ss[1].Trim());
                                }
                            }
                            else
                            {
                                if (ss.Length == 1)
                                {
                                    p = args.GetDefault().GetParameters().Get(ss[0].Trim());
                                }
                            }
                            object v = null;
                            if (p != null)
                            {
                                v = p.GetValue();
                            }
                            if ("long".Equals(type))
                            {
                                if (v == null)
                                {
                                    v = long.Parse(vs[i].Trim());
                                }
                            }
                            else
                            {
                                if ("int".Equals(type))
                                {
                                    if (v == null)
                                    {
                                        v = int.Parse(vs[i].Trim());
                                    }
                                }
                                else
                                {
                                    if ("float".Equals(type))
                                    {
                                        if (v == null)
                                        {
                                            v = float.Parse(vs[i].Trim());
                                        }
                                    }
                                    else
                                    {
                                        if ("double".Equals(type))
                                        {
                                            if (v == null)
                                            {
                                                v = double.Parse(vs[i].Trim());
                                            }
                                        }
                                        else
                                        {
                                            if ("string".Equals(type))
                                            {
                                                if (v == null)
                                                {
                                                    v = vs[i].Trim().ToString();
                                                }
                                            }
                                            else
                                            {
                                                if ("boolean".Equals(type))
                                                {
                                                    if (v == null)
                                                    {
                                                        v = bool.Parse(vs[i].Trim());
                                                    }
                                                }
                                                else
                                                {
                                                    throw new GameConfigExpception(fName + "'s type '" + type + "' is not supported.");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            SetValue(target, f, v);
                            System.Console.Out.WriteLine(target.GetType().FullName + "'s " + fName + " -> " + v);
                        }
                        catch (Exception e)
                        {
                            throw new GameConfigExpception("set " + fields + " to " + values + " failed at " + target.GetType().FullName + "\n" + ExceptionUtil.GetExceptionContent(e));
                        }
                    }
                }
            }
        }
Beispiel #28
0
        public virtual bool OnCreate(IEventArgs skill)
        {
            startTime = skill.Rule.ServerTime;

            this.ins       = new HashSet <long>();
            this.showedIds = new HashSet <long>();
            this.realKey   = FreeUtil.ReplaceVar(key, skill);
            this.realTime  = FreeUtil.ReplaceInt(time, skill);
            this.paras     = new SimpleParaList();

            this.posindex = -1;
            ParaList list = skill.GetDefault().GetParameters();

            if (list.HasPara("posindex"))
            {
                posindex = (int)list.Get("posindex").GetValue();
            }
            skill.TempUse("buf", this);

            IPosSelector pos = GetPos(region.GetCenter(skill));

            if (pos.Select(skill).GetInvalid())
            {
                return(false);
            }

            bool hasCreator = false;

            if (creator != null && creator.hasFreeData)
            {
                skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData);
                hasCreator = true;
            }
            AddParas(skill);
            if (createAction != null)
            {
                createAction.Act(skill);
            }
            if (effectAction != null)
            {
                effectAction.SetSelector(pos);
                effectAction.SetKey("bufeffect_" + realKey);
            }
            else
            {
                if (show == null)
                {
                    show = new FreeEffectShowAction();
                    show.SetKey(effect);
                    show.SetPos(pos);
                }
            }
            skill.Resume("buf");
            if (creator != null && hasCreator)
            {
                skill.Resume("creator");
            }
            if (!StringUtil.IsNullOrEmpty(condition))
            {
                bufCondition = new ExpParaCondition(FreeUtil.ReplaceVar(condition, skill));
            }
            return(true);
        }
Beispiel #29
0
        public virtual void Draw(SimpleInventoryUI ui, IEventArgs args, ItemInventory inventory, ItemPosition ip)
        {
            this.inventory = inventory;
            if (fui == null)
            {
                fui = new FreeUICreateAction();
                Sharpen.Collections.AddAll(fui.GetComponents(), components);
            }
            ip.GetParameters().AddPara(new StringPara("inventory", inventory.GetName()));
            StringPara img      = new StringPara("img", string.Empty);
            StringPara itemName = new StringPara("name", string.Empty);
            IntPara    count    = new IntPara("count", 0);

            args.GetDefault().GetParameters().TempUse(img);
            args.GetDefault().GetParameters().TempUse(count);
            args.GetDefault().GetParameters().TempUse(itemName);

            img.SetValue(ip.GetKey().GetImg());
            count.SetValue(ip.GetCount());
            itemName.SetValue(ip.GetKey().GetName());
            FreeImageComponet back = GetBackground();

            if (ui.nomouse)
            {
                back.SetNoMouse("true");
            }
            if (ui.itemFixed)
            {
                back.SetFixed("true");
            }
            int startX = GetX(args, ui, ip, back);
            int startY = GetY(args, ui, ip, back);

            if (!StringUtil.IsNullOrEmpty(notused) && !StringUtil.IsNullOrEmpty(used))
            {
                if (ip.IsUsed())
                {
                    back.SetUrl(used);
                }
                else
                {
                    back.SetUrl(notused);
                }
            }
            back.SetX(startX.ToString());
            back.SetY(startY.ToString());
            back.SetRelative(ui.relative);
            back.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
            FreeImageComponet itemImg         = back;
            FreeImageComponet secondComponent = GetItemImage();

            if (secondComponent != null)
            {
                back.SetEvent(string.Empty);
                itemImg = secondComponent;
            }
            if (ui.nomouse)
            {
                itemImg.SetNoMouse("true");
            }
            if (ui.itemFixed)
            {
                itemImg.SetFixed("true");
            }
            itemImg.SetUrl(ip.GetKey().GetImg());
            itemImg.SetOriginalSize(ip.GetKey().GetItemWidth() + "," + ip.GetKey().GetItemHeight());
            if (itemImg == back)
            {
                AdjustSize(args, ui, ip, inventory, back, itemImg, startX, startY);
            }
            else
            {
                AdjustSize(args, ui, ip, inventory, back, itemImg, 0, 0);
            }
            SetCount(ip);
            fui.SetKey(ip.GetUIKey());
            fui.SetShow(inventory.IsOpen());
            fui.SetScope(1);
            fui.SetPlayer("current");
            fui.Act(args);
            UpdateHotKey(ui, args, ip);
            args.GetDefault().GetParameters().Resume("img");
            args.GetDefault().GetParameters().Resume("name");
            args.GetDefault().GetParameters().Resume("count");
        }