public void SendMessage(IEventArgs args, SimpleProto message, int scope, string player)
 {
     //PlayerEntity[] players = args.GameContext.player.GetInitializedPlayerEntities();
     PlayerEntity[] players = args.GameContext.player.GetEntities();
     if (scope == 4)
     {
         foreach (PlayerEntity p in players)
         {
             if (p.hasNetwork)
             {
                 p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
             }
         }
     }
     else if (scope == 1)
     {
         IParable unit = args.GetUnit(FreeUtil.ReplaceVar(player, args));
         if (unit != null)
         {
             PlayerEntity p = ((FreeData)unit).Player;
             if (p.hasNetwork)
             {
                 p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
             }
         }
     }
 }
Example #2
0
        public override void DoAction(IEventArgs args)
        {
            UnitPara up   = UnitPara.Parse(FreeUtil.ReplaceVar(this.para, args))[0];
            IPara    para = up.GetPara(args);

            if (para != null)
            {
                double d = FreeUtil.ReplaceDouble(formula, args);
                if (para is IntPara)
                {
                    para.SetValue("=", new IntPara(string.Empty, (int)d));
                }
                if (para is FloatPara)
                {
                    para.SetValue("=", new FloatPara(string.Empty, (float)d));
                }
                if (para is DoublePara)
                {
                    para.SetValue("=", new DoublePara(string.Empty, d));
                }
                else
                {
                    IPara v = new DoublePara("v", d);
                    para.SetValue("=", v);
                }
            }
        }
Example #3
0
        private void CreateItemFromItemDrop(IEventArgs fr, Vector3 p, ItemDrop drop, string realName)
        {
            FreeMoveEntity en = fr.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(fr.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            en.AddPosition();
            en.position.Value = new Vector3(p.x, p.y, p.z);

            en.AddFreeData(FreeUtil.ReplaceVar(name, fr), null);
            en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            if (type == 1)
            {
                en.freeData.Cat = FreeEntityConstant.DeadBox;
            }
            else if (type == 2)
            {
                en.freeData.Cat = FreeEntityConstant.DropBox;
            }

            en.AddFlagImmutability(fr.GameContext.session.currentTimeObject.CurrentTime);

            SimpleItemInfo info = new SimpleItemInfo(realName, drop.cat, drop.id, drop.count, en.entityKey.Value.EntityId);

            en.freeData.Value = SingletonManager.Get <DeadBoxParser>().ToString(info);

            en.isFlagSyncNonSelf = true;
        }
Example #4
0
        public override void DoAction(IEventArgs args)
        {
            string realKeys = FreeUtil.ReplaceVar(keys, args);

            if (!cache.ContainsKey(realKeys))
            {
                string[] ks = StringUtil.Split(realKeys, new string[] { ",", "," });
                ks = GetSpecialString(ks);
                int[] priority = new int[ks.Length];
                for (int i = 0; i < ks.Length; i++)
                {
                    string   k  = ks[i];
                    string[] vs = StringUtil.Split(k, "=");
                    if (vs.Length == 2 && StringUtil.IsNumberString(vs[1]))
                    {
                        ks[i]       = vs[0].Trim();
                        priority[i] = NumberUtil.GetInt(vs[1]);
                    }
                    else
                    {
                        priority[i] = 1;
                    }
                }
                RandomStringAction.KeyProperty kp = new RandomStringAction.KeyProperty();
                kp.v            = realKeys;
                kp.ks           = ks;
                kp.priority     = priority;
                cache[realKeys] = kp;
            }
            string[] ks_1   = cache[realKeys].ks;
            int[]    proAcc = cache[realKeys].priority;
            if (all)
            {
                for (int i = 0; i < ks_1.Length; i++)
                {
                    HandleOne(ks_1.Length, i + 1, ks_1[i], args);
                }
            }
            else
            {
                if (StringUtil.IsNullOrEmpty(count))
                {
                    count = "1";
                }
                int   c   = FreeUtil.ReplaceInt(count, args);
                int[] ins = null;
                if (repeat)
                {
                    ins = RandomUtil.RandomWithProRepeat(0, proAcc, c);
                }
                else
                {
                    ins = RandomUtil.RandomWithPro(0, proAcc, c);
                }
                for (int i = 0; i < ins.Length; i++)
                {
                    HandleOne(ins.Length, i + 1, ks_1[ins[i]], args);
                }
            }
        }
Example #5
0
        public override void DoAction(IEventArgs args)
        {
            string realKey = FreeUtil.ReplaceVar(key, args);

            if (realKey == "sc")
            {
                int c = args.GameContext.sceneObject.GetEntities().Length;

                args.TempUsePara(new StringPara("info", c.ToString()));

                action.Act(args);

                args.ResumePara("info");
            }

            if (realKey == "mp")
            {
                List <MapConfigPoints.ID_Point> ps = MapConfigPoints.current.IDPints;

                List <string> list = new List <string>();
                foreach (MapConfigPoints.ID_Point p in ps)
                {
                    list.Add(p.ID + "=" + p.points.Count);
                }

                args.TempUsePara(new StringPara("info", StringUtil.GetStringFromStrings(list, ", ")));

                action.Act(args);

                args.ResumePara("info");
            }
        }
Example #6
0
        protected override void BuildMessage(IEventArgs args)
        {
            builder.Key = FreeMessageConstant.DuplicateUI;

            builder.Ss.Add(FreeUtil.ReplaceVar(key, args) + FreeMessageConstant.SpilterField + FreeUtil.ReplaceVar(type, args));

            builder.Fs.Add(FreeUtil.ReplaceFloat(x, args));
            builder.Fs.Add(FreeUtil.ReplaceFloat(y, args));

            builder.Bs.Add(FreeUtil.ReplaceBool(show, args));

            builder.Ks.Add(FreeUtil.ReplaceInt(relative, args));

            if (values != null)
            {
                foreach (IFreeUIValue com in values)
                {
                    builder.Ks.Add(com.GetSeq(args));
                    builder.Ins.Add(com.GetAutoStatus() * 100 + com.GetAutoIndex());
                }
                foreach (IFreeUIValue com_1 in values)
                {
                    object obj = com_1.GetValue(args);
                    if (obj == null)
                    {
                        builder.Ss.Add("null");
                    }
                    else
                    {
                        builder.Ss.Add(obj.ToString());
                    }
                }
            }
        }
Example #7
0
        public override void DoAction(IEventArgs args)
        {
            if (values == null)
            {
                values = new List <ArgValue>();
            }

            foreach (CommonGameAction function in args.Functions)
            {
                if (function.GetKey() == FreeUtil.ReplaceVar(key, args))
                {
                    GameFunc func = function.ToGameFunc();
                    checkArg(func);

                    try
                    {
                        //long mem = GC.GetTotalMemory(false);
                        func.Action(values, args);
                        //Debug.LogFormat("call func {0}, args:{1}, memory:{2}", key, ToArgString(), GC.GetTotalMemory(false) - mem);
                        if (FreeLog.IsEnable())
                        {
                            FreeLog.CallFunc(string.Format("call func:{0}, args:{1}", key, ToArgString()));
                        }
                    }
                    catch (Exception e)
                    {
                        FreeLog.Error("call func " + key + " failed.\n"
                                      + ExceptionUtil.GetExceptionContent(e), this);
                    }

                    break;
                }
            }
        }
Example #8
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (items != null)
            {
                foreach (FreeItem fi in items)
                {
                    if (!FreeItemManager.ContainsItem(args.Rule.FreeType, FreeUtil.ReplaceVar(fi.GetKey(), args)))
                    {
                        FreeGameItem gi = (FreeGameItem)fi.Clone();
                        gi.SetItemStack(FreeUtil.ReplaceVar(gi.GetItemStackVar(), args));
                        gi.SetKey(FreeUtil.ReplaceVar(gi.GetKey(), args));
                        gi.SetImg(FreeUtil.ReplaceVar(gi.GetImg(), args));
                        gi.SetName(FreeUtil.ReplaceVar(gi.GetName(), args));
                        gi.SetDesc(FreeUtil.ReplaceVar(gi.GetDesc(), args));
                        gi.SetCat(FreeUtil.ReplaceVar(gi.GetCat(), args));
                        gi.SetIconSize(FreeUtil.ReplaceVar(gi.GetIconSize(), args));
                        gi.SetWidth(FreeUtil.ReplaceNumber(gi.GetWidth(), args));
                        gi.SetHeight(FreeUtil.ReplaceNumber(gi.GetHeight(), args));
                        gi.Created(fr);
                        FreeItemManager.AddItem(args, args.Rule.FreeType, gi);
                    }
                }
            }
        }
Example #9
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (!StringUtil.IsNullOrEmpty(entity))
            {
                object obj = fr.GetEntity(FreeUtil.ReplaceVar(entity, args));
                if (obj is FreeMoveEntity)
                {
                    fr.TempUse("entity", (FreeEntityData)((FreeMoveEntity)obj).freeData.FreeData);
                    action.Act(args);
                    fr.Resume("entity");
                }
            }
            else
            {
                foreach (FreeMoveEntity free in ((Contexts)(fr.GameContext)).freeMove.GetEntities())
                {
                    if (free.hasFreeData && free.freeData.FreeData != null)
                    {
                        fr.TempUse("entity", (FreeEntityData)free.freeData.FreeData);

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

                        fr.Resume("entity");
                    }
                }
            }
        }
Example #10
0
        public override void DoAction(IEventArgs args)
        {
            string from     = FreeUtil.ReplaceVar(ParaFrom, args);
            string to       = FreeUtil.ReplaceVar(ParaTo, args);
            string itemCat  = FreeUtil.ReplaceVar(ParaItemCat, args);
            int    clipType = FreeUtil.ReplaceInt(ParaClipType, args);

            IParable item = args.GetUnit(FreeArgConstant.Item);

            if (to == ChickenConstant.BagDefault && itemCat == ChickenConstant.ItemCatGrenadeWeapon)
            {
                HandleAddGrenade(args);
            }
            if (from == ChickenConstant.BagDefault && itemCat == ChickenConstant.ItemCatGrenadeWeapon)
            {
                HandleRemoveGrenade(args);
            }
            if (to == ChickenConstant.BagDefault && item.GetParameters().HasPara(ClipType))
            {
                HandleSetClip(args, clipType);
            }
            else if (from == ChickenConstant.BagDefault && item.GetParameters().HasPara(ClipType))
            {
                HandleClearClip(args, clipType);
            }

            HandleCapacity(args);
        }
Example #11
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (StringUtil.IsNullOrEmpty(count) || count.Equals("0"))
            {
                count = INI_COUNT;
            }
            int      c    = FreeUtil.ReplaceInt(count, args);
            FreeItem item = FreeItemManager.GetItem(fr, FreeUtil.ReplaceVar(key, args), c);

            if (item != null)
            {
                if (!StringUtil.IsNullOrEmpty(time))
                {
                    ((FreeGameItem)item).SetTime(time);
                }
                item.Drop(fr, pos.Select(args));
                if (action != null)
                {
                    args.TempUse(ParaConstant.PARA_ITEM, item);
                    action.Act(args);
                    args.Resume(ParaConstant.PARA_ITEM);
                }
            }
        }
Example #12
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;
            IGameUnit         player = GetPlayer(args);

            if (StringUtil.IsNullOrEmpty(count) || count.Equals("0"))
            {
                count = "0";
            }
            method = new SelectMethod(FreeUtil.ReplaceVar(exp, args));
            if (player != null)
            {
                FreeData       fd           = (FreeData)player;
                ItemPosition[] currentItems = fd.freeInventory.Select(method);
                fr.TempUse("current", fd);
                int c = FreeUtil.ReplaceInt(count, args);
                for (int i = 0; i < currentItems.Length; i++)
                {
                    ItemPosition ip = currentItems[i];
                    ip.SetCount(c);
                    ip.GetKey().SetCount(c);
                    ip.GetInventory().GetInventoryUI().UpdateItem(fr, ip.GetInventory(), ip);
                }
                fr.Resume("current");
            }
        }
 protected override void BuildMessage(IEventArgs args)
 {
     builder.Key = 62;
     builder.Ss.Add(FreeUtil.ReplaceVar(key, args));
     if (values != null)
     {
         foreach (IFreeUIValue com in values)
         {
             builder.Ks.Add(com.GetSeq(args));
             builder.Ins.Add(com.GetAutoStatus() * 100 + com.GetAutoIndex());
         }
         foreach (IFreeUIValue com_1 in values)
         {
             object obj = com_1.GetValue(args);
             if (obj == null)
             {
                 builder.Ss.Add("null");
             }
             else
             {
                 builder.Ss.Add(obj.ToString());
             }
         }
     }
 }
Example #14
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)
                    {
                        ParaListSet temp = pls.Sort(FreeUtil.ReplaceVar(exp, args));
                        temp.SetName(pls.GetName());
                        unit.GetParameters().TempUse(temp);
                        action.Act(args);
                        unit.GetParameters().Resume(temp.GetName());
                    }
                    if (!keep)
                    {
                        pls.ReOrder();
                    }
                }
            }
        }
Example #15
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);
                    }
                }
            }
        }
Example #16
0
 public override string GetScale(IEventArgs args)
 {
     if (text != null)
     {
         scale = text.width + "," + text.height + ",0";
     }
     return(FreeUtil.ReplaceVar(scale, args));
 }
Example #17
0
 public override void DoAction(IEventArgs args)
 {
     string[] ks = StringUtil.Split(FreeUtil.ReplaceVar(keys, args), new string[] { RECORD_SPLITER });
     for (int i = 0; i < ks.Length; i++)
     {
         string[] vs = StringUtil.Split(ks[i], new string[] { FIELD_SPLITER });
         HandleOne(ks.Length, i + 1, vs, args);
     }
 }
Example #18
0
        public override void DoAction(IEventArgs args)
        {
            DataRecord dr = new DataRecord();

            dr.AddField("time", DateTime.Now.Ticks.ToString());
            dr.AddField("key", key);
            dr.AddField("message", FreeUtil.ReplaceVar(message, args));
            MysqlUtil.Add(dr, "simple_log", FreeRuleConfig.MysqlConnection);
        }
Example #19
0
 public virtual string GetString(IEventArgs args)
 {
     if (!initialed || dynamic)
     {
         realValue = FreeUtil.ReplaceVar(para, args);
         initialed = true;
     }
     return((string)realValue);
 }
Example #20
0
        public override void DoAction(IEventArgs args)
        {
            IParable parable = args.GetUnit(FreeUtil.ReplaceVar(var, args));

            if (parable != null)
            {
                args.SetPara(FreeUtil.ReplaceVar(name, args), parable);
            }
        }
Example #21
0
        public override void DoAction(IEventArgs args)
        {
            Vector3 p           = UnityPositionUtil.ToVector3(pos.Select(args));
            string  realName    = FreeUtil.ReplaceVar(name, args);
            var     groupEntity = args.GameContext.freeMove.CreateEntity();

            groupEntity.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            groupEntity.AddPosition();
            groupEntity.position.Value = new Vector3(p.x, p.y, p.z);
            groupEntity.AddFreeData("", null);
            groupEntity.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            groupEntity.freeData.Value = "";
            if (type == 1)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DeadBoxGroup;
            }
            else if (type == 2)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DropBoxGroup;
            }
            groupEntity.isFlagSyncNonSelf = true;

            if (string.IsNullOrEmpty(id))
            {
                ItemDrop[] list = FreeItemDrop.GetDropItems(FreeUtil.ReplaceVar(cat, args), FreeUtil.ReplaceInt(count, args), args.GameContext.session.commonSession.RoomInfo.MapId);
                foreach (ItemDrop drop in list)
                {
                    CreateItemFromItemDrop(args, p, drop, realName);
                    List <ItemDrop> extra = FreeItemDrop.GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        CreateItemFromItemDrop(args, p, e, realName);
                    }
                }
            }
            else
            {
                PlayerEntity player = args.GameContext.player.GetEntityWithEntityKey(new EntityKey(FreeUtil.ReplaceInt(id, args), (short)EEntityType.Player));
                if (player != null)
                {
                    groupEntity.freeData.IntValue = player.entityKey.Value.EntityId;
                    groupEntity.freeData.Value    = realName;
                    realName = player.playerInfo.PlayerName;
                    FreeData fd = ((FreeData)player.freeData.FreeData);
                    foreach (string inv in fd.GetFreeInventory().GetInventoryManager().GetInventoryNames())
                    {
                        ItemInventory ii = fd.GetFreeInventory().GetInventoryManager().GetInventory(inv);
                        if (ii.name != ChickenConstant.BagDefault)
                        {
                            CreateItemFromInventory(args, fd, ii, p, realName);
                        }
                    }
                    CreateItemFromInventory(args, fd, fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory(), p, realName);
                }
            }
        }
Example #22
0
        public static void SendMessage(IEventArgs args, string player, SimpleProto message)
        {
            IParable unit = args.GetUnit(FreeUtil.ReplaceVar(player, args));

            if (unit != null)
            {
                PlayerEntity p = ((FreeData)unit).Player;
                p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
            }
        }
Example #23
0
        public virtual void AddFreeBuf(FreeBuf buf, IEventArgs args)
        {
            string key = FreeUtil.ReplaceVar(buf.GetKey(), args);

            if (map.ContainsKey(key))
            {
                FreeLog.Error("buf '" + key + "' 覆盖了原有的BUF", null);
            }
            this.map[key] = buf;
        }
Example #24
0
        public PlayerEntity GetPlayer(string player)
        {
            IParable unit = GetUnit(FreeUtil.ReplaceVar(player, this));

            if (unit is FreeData)
            {
                return(((FreeData)unit).Player);
            }

            return(null);
        }
Example #25
0
 public override void DoAction(IEventArgs args)
 {
     if (key != null)
     {
         foreach (String k in StringUtil.Split(FreeUtil.ReplaceVar(key, args),
                                               new String[] { ",", "," }))
         {
             args.FreeContext.Bufs.RemoveBuf(args, k);
         }
     }
 }
Example #26
0
 public override string ToConfig(IEventArgs args)
 {
     if (!StringUtil.IsNullOrEmpty(id))
     {
         return("point|" + FreeUtil.ReplaceNumber(id, args) + "," + FreeUtil.ReplaceVar(xyz, args) + "|" + FreeUtil.ReplaceVar(delta, args));
     }
     else
     {
         return("point|" + FreeUtil.ReplaceVar(xyz, args) + "|" + FreeUtil.ReplaceVar(delta, args));
     }
 }
Example #27
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr  = (FreeRuleEventArgs)args;
            object            obj = fr.GetEntity(FreeUtil.ReplaceVar(entity, args));

            if (obj is FreeMoveEntity)
            {
                FreeEntityData data = (FreeEntityData)((FreeMoveEntity)obj).freeData.FreeData;
                data.SetMove(args, move);
            }
        }
Example #28
0
 public override object GetValue(IEventArgs args)
 {
     if (value.Contains(","))
     {
         return(FreeUtil.ReplaceVar(value, args));
     }
     else
     {
         return(GetValue(args, value));
     }
 }
Example #29
0
 public override object GetValue(IEventArgs args)
 {
     if (autoStatus > 0)
     {
         return(FreeUtil.ReplaceNumber(url, args));
     }
     else
     {
         return(FreeUtil.ReplaceVar(url, args));
     }
 }
Example #30
0
 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");
         }
     }
 }