Exemple #1
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");
            }
        }
        public static void Handle(IEventArgs args, DebugCommand message, PlayerEntity player)
        {
            if (commandDic.ContainsKey(message.Command.ToLower()))
            {
                FreeLog.Reset();

                IGameAction action = commandDic[message.Command.ToLower()];

                if (FreeLog.IsEnable())
                {
                    FreeLog.SetTrigger(string.Format("命令行 {0}: {1}", message.Command, string.Join(" ", message.Args)));
                }

                if (commandPara == null)
                {
                    commandPara = new StringPara("command", "");
                }

                if (message.Args != null)
                {
                    for (int i = 1; i <= message.Args.Length; i++)
                    {
                        args.TempUsePara(new StringPara("arg" + i, message.Args[i - 1]));
                    }
                }


                args.TempUsePara(commandPara);
                args.TempUse("current", (FreeData)player.freeData.FreeData);

                action.Act(args);

                if (message.Command == "relive")
                {
                    player.isFlagCompensation = true;
                }

                args.Resume("current");
                args.ResumePara("command");

                if (message.Args != null)
                {
                    for (int i = 1; i <= message.Args.Length; i++)
                    {
                        args.ResumePara("arg" + i);
                    }
                }

                FreeLog.Print();
            }
        }
Exemple #3
0
        public void Trigger(IEventArgs args, GameTriggers triggers, int trigger)
        {
            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].unit != null)
                {
                    args.TempUse(units[i].key, units[i].unit);
                }
            }
            for (int i = 0; i < paras.Count; i++)
            {
                args.TempUsePara(paras[i]);
            }

            triggers.Trigger(trigger, args);

            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].unit != null)
                {
                    args.Resume(units[i].key);
                }
            }
            for (int i = 0; i < paras.Count; i++)
            {
                args.ResumePara(paras[i].GetName());
            }

            Reset();
        }
Exemple #4
0
        public void Act(IEventArgs args, IGameAction action)
        {
            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].unit != null)
                {
                    args.TempUse(units[i].key, units[i].unit);
                }
            }
            for (int i = 0; i < paras.Count; i++)
            {
                args.TempUsePara(paras[i]);
            }

            action.Act(args);

            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].unit != null)
                {
                    args.Resume(units[i].key);
                }
            }
            for (int i = 0; i < paras.Count; i++)
            {
                args.ResumePara(paras[i].GetName());
            }

            Reset();
        }
Exemple #5
0
        private void HandlePlayer(Collider collider, IEventArgs fr, Contexts contexts, float damage, Vector3 bombPos)
        {
            var entityReference = collider.transform.GetComponent <EntityReference>();
            var player          = entityReference.Reference as PlayerEntity;

            if (null == player)
            {
                Logger.ErrorFormat("player {0} has no player reference ", collider.name);
                return;
            }
            if (HasObstacle(player.position.Value, player.position.Value + Vector3.up * CeilCheckDistance))
            {
                return;
            }

            /*if (player.IsOnVehicle())
             * {
             *  if (Logger.IsDebugEnabled)
             *  {
             *      Logger.Debug("player in vehicle ");
             *  }
             *  var vehicleEntity = contexts.vehicle.GetEntityWithEntityKey(player.controlledVehicle.EntityKey);
             *  vehicleEntity.GetGameData().DecreaseHp(Core.Prediction.VehiclePrediction.Cmd.VehiclePartIndex.Body, damage);
             * }
             * else
             * {*/
            if (null != action)
            {
                disPara.SetValue(Math.Max(0,
                                          (fr.GetFloat(radius) - Vector3.Distance(bombPos, player.position.Value)) / fr.GetFloat(radius)));
                fr.TempUsePara(damagePara);
                fr.TempUsePara(disPara);
                fr.TempUsePara(typePara);
                fr.TempUse("current", (FreeData)player.freeData.FreeData);
                action.Act(fr);

                fr.ResumePara("damage");
                fr.ResumePara("dis");
                fr.ResumePara("type");
                fr.Resume("current");
            }

            //}
        }
        public override void DoAction(IEventArgs args)
        {
            if (addtimePara == null)
            {
                addtimePara = new IntPara(ParaConstant.PARA_ITEM_ADD_TIME, 0);
            }
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (StringUtil.IsNullOrEmpty(count))
            {
                count = INI_COUNT;
            }
            FreeItem fi = FreeItemManager.GetItem(fr, FreeUtil.ReplaceVar(key, args), FreeUtil.ReplaceInt(count, args));

            if (StringUtil.IsNullOrEmpty(name))
            {
                name = InventoryManager.DEFAULT;
            }
            IGameUnit player = GetPlayer(args);

            if (player != null)
            {
                FreeData fd = (FreeData)player;
                args.TempUse(ParaConstant.PARA_PLAYER_CURRENT, fd);
                args.TempUse(ParaConstant.PARA_ITEM, fi);

                args.TempUsePara(new StringPara("from", ChickenConstant.BagGround));

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

                if (fd.freeInventory.GetInventoryManager().GetInventory(FreeUtil.ReplaceVar(name, args)).AddItem((ISkillArgs)args, fi, true))
                {
                    //addtimePara.setValue(fr.room.getServerTime());
                    fi.GetParameters().AddPara(addtimePara);
                }
                else
                {
                    if (failAction != null)
                    {
                        fr.TempUse(ParaConstant.PARA_ITEM, fi);
                        failAction.Act(args);
                        fr.Resume(ParaConstant.PARA_ITEM);
                    }
                }

                fr.ResumePara("from");
                fr.Resume(ParaConstant.PARA_PLAYER_CURRENT);
                fr.Resume(ParaConstant.PARA_ITEM);
            }
        }
Exemple #7
0
        public bool Meet(IEventArgs args)
        {
            condition.SetValue(false);
            args.TempUsePara(condition);

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

            args.ResumePara(Success);

            return((bool)condition.GetValue());
        }
Exemple #8
0
        public override void DoAction(IEventArgs args)
        {
            long serverTime = args.Rule.ServerTime;

            if (!string.IsNullOrEmpty(time) && realTime == 0)
            {
                realTime = args.GetInt(time);
            }

            if (startTime == 0)
            {
                startTime = serverTime;
                timePara  = new IntPara(Time, 0);
            }

            timePara.SetValue(serverTime - startTime);
            args.TempUsePara(timePara);

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

            if (realTime > 0 && serverTime - startTime >= realTime)
            {
                args.FreeContext.AiSuccess = true;
                startTime = 0;
            }

            if (condition != null && condition.Meet(args))
            {
                args.FreeContext.AiSuccess = true;
                startTime = 0;
            }

            args.ResumePara(Time);
        }
        public override void DoAction(IEventArgs args)
        {
            Ini(args);

            List <FreeData> list = new List <FreeData>();

            foreach (PlayerEntity unit in args.GameContext.player.GetInitializedPlayerEntities())
            {
                if (unit.hasFreeData)
                {
                    FreeData fd = (FreeData)unit.freeData.FreeData;
                    args.TempUse(selectedName, fd);
                    if (con == null || con.Meet(args))
                    {
                        list.Add(fd);
                    }
                    args.Resume(selectedName);
                }
            }

            if (!StringUtil.IsNullOrEmpty(order))
            {
                DataBlock bl = new DataBlock();
                foreach (FreeData fd in list)
                {
                    bl.AddData(fd);
                }
                if (method == null || FreeUtil.IsVar(order))
                {
                    method = new SelectMethod(order);
                }
                list.Clear();
                foreach (IFeaturable fe in method.Select(bl).GetAllDatas())
                {
                    list.Add((FreeData)fe);
                }
            }
            if (list.Count > 0)
            {
                if (count > 0)
                {
                    int[] ids = RandomUtil.Random(0, list.Count - 1, count);
                    if (!StringUtil.IsNullOrEmpty(order))
                    {
                        ids = new int[(int)MyMath.Min(count, list.Count)];
                        for (int i = 0; i < ids.Length; i++)
                        {
                            ids[i] = i;
                        }
                    }
                    for (int i = 0; i < ids.Length; i++)
                    {
                        int      id   = ids[i];
                        FreeData unit = list[id];
                        args.TempUsePara(new IntPara("index", i + 1));
                        args.TempUsePara(new IntPara("count", ids.Length));
                        args.TempUse(selectedName, unit);
                        action.Act(args);
                        args.Resume(selectedName);
                        args.ResumePara("index");
                        args.ResumePara("count");
                    }
                }
                else
                {
                    int i = 1;
                    foreach (FreeData unit in list)
                    {
                        args.TempUsePara(new IntPara("index", i++));
                        args.TempUsePara(new IntPara("count", list.Count));
                        args.TempUse(selectedName, unit);
                        action.Act(args);
                        args.Resume(selectedName);
                        args.ResumePara("index");
                        args.ResumePara("count");
                    }
                }
            }
            else
            {
                if (noneAction != null)
                {
                    noneAction.Act(args);
                }
            }
        }