public override void DoAction(IEventArgs args)
        {
            if (!initialed)
            {
                if (prepare != null)
                {
                    prepare.Act(args);
                }
                initialed = true;
            }
            FreeLog.SetTrigger(trigger);
            order.Act(args);
            if (frame != null)
            {
                frame.Act(args);
            }
            if (args.FreeContext.AiSuccess)
            {
                if (frame is TestCaseMultiAction)
                {
                    ((TestCaseMultiAction)frame).Record(args);
                }

                if (clean != null)
                {
                    clean.Act(args);
                }
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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");
            }
        }
Exemple #4
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");
                    }
                }
            }
        }
 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");
         }
     }
 }
Exemple #6
0
        public bool CanUse(ISkillArgs args)
        {
            if (condition != null && !condition.Meet(args))
            {
                if (notReadyAction != null)
                {
                    notReadyAction.Act(args);
                }
                return(false);
            }

            return(true);
        }
Exemple #7
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);
                }
            }
        }
Exemple #8
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();
                    }
                }
            }
        }
Exemple #9
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();
        }
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

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

            if (player.playerInfo.CampInfo != null && player.playerInfo.CampInfo.Preset.Count > 0 && player.playerInfo.CampInfo.CurrCamp != player.playerInfo.Camp &&
                GameRules.ClothesType(args.GameContext.session.commonSession.RoomInfo.ModeId) != (int)EGameModeClothes.Default)
            {
                foreach (Preset p in player.playerInfo.CampInfo.Preset)
                {
                    if (p.camp == player.playerInfo.Camp)
                    {
                        player.gamePlay.NewRoleId = p.roleModelId;
                        break;
                    }
                }
            }
            else
            {
                var ids = (player.playerInfo.AvatarIds == null || player.playerInfo.AvatarIds.Count == 0) ? player.playerInfo.CacheAvatarIds : player.playerInfo.AvatarIds;
                for (int i = 0; i < (ids == null ? 0 : ids.Count); i++)
                {
                    var resId  = SingletonManager.Get <RoleAvatarConfigManager>().GetResId(ids[i], player.GetSex());
                    var avatar = SingletonManager.Get <AvatarAssetConfigManager>().GetAvatarAssetItemById(resId);
                    if (avatar != null)
                    {
                        player.appearanceInterface.Appearance.ChangeAvatar(resId);
                    }
                }
            }
        }
Exemple #11
0
 public virtual bool Effect(ISkillArgs args)
 {
     if (isGoods)
     {
         args.TempUse("item", this);
         if (buyAction != null)
         {
             buyAction.Act(args);
         }
         args.Resume("item");
         return(true);
     }
     if (condition == null || condition.Meet(args))
     {
         if (clickSkill != null && args != null)
         {
             args.TempUse("item", this);
             this.clickSkill.Frame(args);
             args.Resume("item");
         }
         return(true);
     }
     else
     {
         if (condition != null && !condition.Meet(args))
         {
             if (notReadyAction != null)
             {
                 notReadyAction.Act(args);
             }
         }
     }
     return(false);
 }
Exemple #12
0
 public override ISkillTrigger.TriggerStatus Triggered(ISkillArgs args)
 {
     if (interrupter != null && interrupter.IsInterrupted(args))
     {
         if (startTime > 0)
         {
             startTime = 0;
             if (interAction != null)
             {
                 interAction.Act(args);
             }
             return(ISkillTrigger.TriggerStatus.Interrupted);
         }
         startTime = 0;
     }
     if (startTrigger == null || startTrigger.Triggered(args) == ISkillTrigger.TriggerStatus.Success)
     {
         if (startTime == 0)
         {
             startTime = Runtime.CurrentTimeMillis();
             if (castAction != null)
             {
                 castAction.Act(args);
             }
         }
     }
     if (startTime > 0 && Runtime.CurrentTimeMillis() - startTime >= time)
     {
         startTime = 0;
         return(ISkillTrigger.TriggerStatus.Success);
     }
     return(ISkillTrigger.TriggerStatus.Failed);
 }
Exemple #13
0
 public override void DoAction(IEventArgs args)
 {
     FreeLog.SetTrigger(trigger);
     order.Act(args);
     if (frame != null)
     {
         frame.Act(args);
     }
     if (args.FreeContext.AiSuccess)
     {
         if (frame is TestCaseMultiAction)
         {
             ((TestCaseMultiAction)frame).Record(args);
         }
     }
 }
Exemple #14
0
        public virtual void Action(IList <ArgValue> funcArgs, IEventArgs args)
        {
            long s = FreeTimeDebug.RecordStart("call " + name + "(" + key + ")");

            FreeLog.CallFunc("call " + name + "(" + key + "):");
            if (funcArgs != null)
            {
                foreach (FuncArg arg in this.args)
                {
                    SetArg(arg, funcArgs, args);
                }
            }
            if (action != null)
            {
                action.Act(args);
            }
            if (funcArgs != null)
            {
                foreach (FuncArg arg in this.args)
                {
                    RemoveArg(arg, args);
                }
            }
            FreeTimeDebug.RecordEnd("call " + name + "(" + key + ")", s);
        }
 public override void Effect(ISkillArgs args)
 {
     if (effect != null)
     {
         effect.Act(args);
     }
 }
 public void Act(IGameAction action)
 {
     if (action != null)
     {
         action.Act(this);
     }
 }
Exemple #17
0
 public override void Initial(ISkillArgs args)
 {
     if (initial != null)
     {
         initial.Act(args);
     }
 }
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            if (player == null)
            {
                return;
            }

            if (args.Rule.ServerTime - player.statisticsData.Statistics.LastDeadTime <= 2900L)
            {
                return;
            }

            int oldObserveId = player.gamePlay.CameraEntityId;

            bool success = ObservePlayer(args, player, args.GetBool(observeEnemy), args.GetBool(wise));

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

            if (oldObserveId != player.gamePlay.CameraEntityId)
            {
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerObserveTrigger;
                sp.Bs.Add(true);
                FreeMessageSender.SendMessage(player, sp);
            }
        }
Exemple #19
0
        public void Turn()
        {
            GetAvailableMoves(CurrentTeamId);

            this.NeedSubTurnPirate       = null;
            this.PreviosSubTurnDirection = null;

            if (_availableMoves.Count > 0) //есть возможные ходы
            {
                int moveNo;
                if (_availableMoves.Count == 1) //только один ход, сразу выбираем его
                {
                    moveNo = 0;
                }
                else //запрашиваем ход у игрока
                {
                    GameState gameState = new GameState();
                    gameState.AvailableMoves = _availableMoves.ToArray();
                    gameState.Board          = Board;
                    gameState.GameId         = GameId;
                    gameState.TurnNumber     = TurnNo;
                    gameState.SubTurnNumber  = SubTurnNo;
                    gameState.TeamId         = CurrentTeamId;
                    moveNo = CurrentPlayer.OnMove(gameState);
                }

                IGameAction action = _actions[moveNo];
                Pirate      pirate = Board.Teams[CurrentTeamId].Pirates.First(x => x.Position == _availableMoves[moveNo].From);
                action.Act(this, pirate);
            }
            else //у нас нет возможных ходов - тогда если все трезвые, то все гибнут
            {
                var  allPirates         = Board.Teams[CurrentTeamId].Pirates.ToList();
                bool allNotDrunkPirates = allPirates.All(x => x.IsDrunk == false);
                if (allNotDrunkPirates)
                {
                    foreach (var pirate in allPirates)
                    {
                        KillPirate(pirate);
                    }
                }
            }

            if (this.NeedSubTurnPirate == null)
            {
                //также протрезвляем всех пиратов, которые начали бухать раньше текущего хода
                foreach (Pirate pirate in Board.Teams[CurrentTeamId].Pirates.Where(x => x.IsDrunk && x.DrunkSinceTurnNo < TurnNo))
                {
                    pirate.DrunkSinceTurnNo = null;
                    pirate.IsDrunk          = false;
                }

                TurnNo++;
                SubTurnNo = 0;
            }
            else
            {
                SubTurnNo++;
            }
        }
 public override void Resume(ISkillArgs args)
 {
     if (resume != null)
     {
         resume.Act(args);
     }
 }
Exemple #21
0
 public virtual void Added(ISkillArgs args)
 {
     if (addAction != null && args != null)
     {
         args.TempUse("item", this);
         addAction.Act(args);
         args.Resume("item");
     }
 }
Exemple #22
0
        public void Start(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            args.TempUse("entity", this);
            args.TempUse(name, this);

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

            FreeData creator = (FreeData)args.GetUnit("creator");

            if (creator != null)
            {
                CreatorId = creator.Player.playerInfo.EntityId;
            }

            if (skills != null && skills.Count > 0)
            {
                skill = new UnitSkill(this);
                foreach (ISkill sk in skills)
                {
                    skill.AddSkill(sk);
                }
            }

            move.Start(fr, _entity);

            xPara.SetValue(_entity.position.Value.x);
            yPara.SetValue(_entity.position.Value.y);
            zPara.SetValue(_entity.position.Value.z);

            if (effect != null)
            {
                AutoPositionValue auto = new AutoPositionValue();
                auto.SetId(_entity.entityKey.Value.EntityId.ToString());
                auto.SetField("pos");
                effect.AddAuto(auto);

                AutoScaleValue scale = new AutoScaleValue();
                scale.SetId(_entity.entityKey.Value.EntityId.ToString());
                scale.SetField("scale");
                effect.AddAuto(scale);

                effect.SetSelector(new PosAssignSelector(_entity.position.Value.x.ToString(),
                                                         _entity.position.Value.y.ToString(), _entity.position.Value.z.ToString()));

                //Debug.LogFormat("start pos {0}", _entity.position.Value.ToString());

                effect.Act(args);
            }

            args.Resume(name);
            args.Resume("entity");
        }
Exemple #23
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");
        }
Exemple #24
0
 public virtual void Removed(ISkillArgs args)
 {
     if (removeAction != null && args != null)
     {
         args.TempUse("item", this);
         removeAction.Act(args);
         args.Resume("item");
     }
 }
Exemple #25
0
 public virtual void Created(ISkillArgs args)
 {
     if (createAction != null && args != null)
     {
         args.TempUse("item", this);
         createAction.Act(args);
         args.Resume("item");
     }
 }
        public override void DoAction(IEventArgs args)
        {
            args.FreeContext.AiSuccess = true;

            if (action != null)
            {
                action.Act(args);
            }
        }
Exemple #27
0
        public override bool Frame(FreeRuleEventArgs args, FreeMoveEntity entity, int interval)
        {
            if (dynamic)
            {
                tempPosition = targetPos.Select(args);
            }

            float speedMeter = GetSpeed(args, entity).GetSpeed(args, interval);

            float dis = speedMeter * (float)interval / 1000f;

            if (tempPosition.Distance(GetEntityPosition(entity)) < dis)
            {
                UnityPositionUtil.SetUnitPositionToEntity(entity.position, tempPosition);

                if (action != null && !firstTime)
                {
                    args.TempUsePara(new FloatPara("x", entity.position.Value.x));
                    args.TempUsePara(new FloatPara("y", entity.position.Value.y));
                    args.TempUsePara(new FloatPara("z", entity.position.Value.z));

                    action.Act(args);

                    args.ResumePara("x");
                    args.ResumePara("y");
                    args.ResumePara("z");

                    firstTime = true;
                }

                if (!stayTarget)
                {
                    return(true);
                }
            }
            else
            {
                Vector3      from = entity.position.Value;
                UnitPosition ep   = GetEntityPosition(entity);
                UnityPositionUtil.Move(ep, tempPosition, dis);

                entity.position.Value = new Vector3(ep.GetX(), ep.GetY(), ep.GetZ());

                if (hitType > 0)
                {
                    bool hit = CheckHit(args, (FreeEntityData)entity.freeData.FreeData, from, entity.position.Value, dis);

                    if (hit)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
 private void Warning(ISkillArgs args, IGameAction action)
 {
     if (trigger != null && trigger.Triggered(args) == ISkillTrigger.TriggerStatus.Success)
     {
         if (action != null)
         {
             action.Act(args);
         }
     }
 }
Exemple #29
0
        public void Frame(IEventArgs args, int interval)
        {
            if (_entity.isFlagDestroy)
            {
                return;
            }
            args.TempUse("entity", this);
            args.TempUse(name, this);

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            move.Frame(fr, _entity, interval);

            xPara.SetValue(_entity.position.Value.x);
            yPara.SetValue(_entity.position.Value.y);
            zPara.SetValue(_entity.position.Value.z);

            foreach (PlayerEntity player in follows)
            {
                Vector3 v = _entity.position.Value;
                //v.y = v.y + 20;
                player.position.Value = v;
            }
            if (gameObject != null)
            {
                gameObject.transform.position = _entity.position.Value;
            }

            if (skill != null)
            {
                skill.Frame((FreeRuleEventArgs)args);
            }

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

            if (effect != null && args.Rule.ServerTime - lastEffectTime > 1000L)
            {
                foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities())
                {
                    if (!effect.GetPlayerIds().Contains(player.entityKey.Value.EntityId))
                    {
                        effect.Act(args);
                        effect.AddPlayerId(player.entityKey.Value.EntityId);
                        lastEffectTime = args.Rule.ServerTime;
                        break;
                    }
                }
            }
            args.Resume(name);
            args.Resume("entity");
        }
Exemple #30
0
 public override void DoAction(IEventArgs args)
 {
     if (code < actions.Length)
     {
         IGameAction action = actions[code];
         if (action != null)
         {
             action.Act(args);
         }
     }
 }