Exemple #1
0
            public virtual void Frame(ISkillArgs args, IGameUnit unit, int range)
            {
                if (con == null && !StringUtil.IsNullOrEmpty(condition))
                {
                    con = new ExpParaCondition(condition);
                }
                BaseEventArgs bea = (BaseEventArgs)args;

                bea.TempUse("give", unit);
                foreach (IGameUnit gu in args.GetGameUnits())
                {
                    if (((XYZPara.XYZ)gu.GetXYZ().GetValue()).Distance(((XYZPara.XYZ)unit.GetXYZ().GetValue())) <= range)
                    {
                        bea.TempUse("get", gu);
                        if (con == null || con.Meet(args))
                        {
                            effect.SetKey(this.key);
                            effect.SetSource(unit.GetID());
                            if (effect.GetTime() < 200)
                            {
                                effect.SetTime(200);
                            }
                            gu.GetUnitSkill().AddSkillEffect(effect);
                        }
                        bea.Resume("get");
                    }
                }
                bea.Resume("give");
            }
        public override UnitPosition Select(IEventArgs args)
        {
            IniCon();

            UnitPosition up = new UnitPosition();

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (!string.IsNullOrEmpty(player))
            {
                object obj = fr.GetEntity(player);
                if (obj != null)
                {
                    if (obj is PlayerEntity)
                    {
                        PlayerEntity playerEntity = (PlayerEntity)obj;
                        fr.TempUse("current", (FreeData)playerEntity.freeData.FreeData);

                        UnityPositionUtil.SetPlayerToUnitPosition(playerEntity, up);
                        if (fromEye)
                        {
                            up.SetY(up.GetY() + 1.7f);
                        }

                        fr.Resume("current");
                    }

                    if (obj is FreeMoveEntity)
                    {
                        FreeMoveEntity playerEntity = (FreeMoveEntity)obj;
                        fr.TempUse("current", (FreeEntityData)playerEntity.freeData.FreeData);

                        UnityPositionUtil.SetEntityToUnitPosition(playerEntity.position, up);

                        fr.Resume("current");
                    }
                }
            }
            else if (!string.IsNullOrEmpty(condition))
            {
                if (con == null || con.Meet(args))
                {
                    foreach (PlayerEntity unit in args.GameContext.player.GetInitializedPlayerEntities())
                    {
                        if (unit.hasFreeData)
                        {
                            fr.TempUse("current", (FreeData)unit.freeData.FreeData);

                            UnityPositionUtil.SetPlayerToUnitPosition(unit, up);

                            fr.Resume("current");
                        }
                    }
                }
            }

            return(GetPosition(args, up, FreeUtil.ReplaceFloat(angle, args) + up.GetYaw()));
        }
Exemple #3
0
 public override ISkillTrigger.TriggerStatus Triggered(ISkillArgs args)
 {
     if (conditon == null && !StringUtil.IsNullOrEmpty(exp))
     {
         conditon = new ExpParaCondition(exp);
     }
     if (action != null)
     {
         action.Act(args);
     }
     if (conditon == null || conditon.Meet(args))
     {
         return(IsInter(args));
     }
     else
     {
         return(ISkillTrigger.TriggerStatus.Failed);
     }
 }
        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);
                }
            }
        }