Exemple #1
0
        public override bool IsIn(IEventArgs args, UnitPosition entity)
        {
            if (pos == null || change)
            {
                pos = selector.Select(args);
            }
            float r = 0f;

            try
            {
                r = float.Parse(radius);
            }
            catch (Exception)
            {
                r = FreeUtil.ReplaceFloat(radius, args);
            }

            double dx = MyMath.Abs(entity.GetX() - pos.GetX());

            if (dx > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dz = MyMath.Abs(entity.GetZ() - pos.GetZ());

            if (dz > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dy     = MyMath.Abs(entity.GetY() - pos.GetY());
            float  zrange = FreeUtil.ReplaceFloat(zRange, args);

            if (zrange <= 0)
            {
                zrange = 170;
            }

            bool isIn = (dx * dx + dz * dz) <= r * r && (dy < zrange);

            if (useOut)
            {
                return(!isIn);
            }
            return(isIn);
        }
Exemple #2
0
        // 一个位置向另外一个位置移动一段距离后的点位置, 修改from的值
        public static void Move(UnitPosition from, UnitPosition target, float dis)
        {
            Vector3 v = new Vector3(target.GetX() - from.GetX(), target.GetY() - from.GetY(), target.GetZ() - from.GetZ());

            if (v.magnitude != 0)
            {
                float scale = dis / v.magnitude;

                from.SetX(from.GetX() + v.x * scale);
                from.SetY(from.GetY() + v.y * scale);
                from.SetZ(from.GetZ() + v.z * scale);
            }
        }
Exemple #3
0
        public override void DoAction(IEventArgs args)
        {
            int realType = args.GetInt(type);
            int dis      = args.GetInt(distance);

            int i = 1;

            UnitPosition up     = pos.Select(args);
            Vector3      target = new Vector3(up.GetX(), up.GetY(), up.GetZ());

            foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(args.GameContext.session.commonSession.RoomInfo.MapId).IDPints)
            {
                if (p.ID == realType)
                {
                    foreach (MapConfigPoints.SavedPointData v in p.points)
                    {
                        if (IsNear(v.pos, target, dis))
                        {
                            TriggerArgs ta = new TriggerArgs();
                            ta.AddPara(new FloatPara("x", v.pos.x));
                            ta.AddPara(new FloatPara("y", v.pos.y));
                            ta.AddPara(new FloatPara("z", v.pos.z));
                            ta.AddPara(new FloatPara("index", i++));

                            args.Act(action, ta);
                        }
                    }
                }
            }
        }
Exemple #4
0
        public override bool IsIn(IEventArgs args, UnitPosition entity)
        {
            bool isIn = false;

            foreach (MapConfigPoints.ID_Point p in MapConfigPoints.current.IDPints)
            {
                if (p.ID == FreeUtil.ReplaceInt(type, args))
                {
                    foreach (MapConfigPoints.SavedPointData spd in p.points)
                    {
                        float dx = MyMath.Abs(entity.GetX() - spd.pos.x);
                        float dz = MyMath.Abs(entity.GetZ() - spd.pos.z);
                        float dy = MyMath.Abs(entity.GetY() - spd.pos.y);
                        if (dx * dx + dz * dz <= spd.cylinderVolR * spd.cylinderVolR && dy <= spd.cylinderVolH)
                        {
                            isIn = true;
                            break;
                        }
                    }

                    if (isIn)
                    {
                        break;
                    }
                }
            }

            if (useOut)
            {
                return(!isIn);
            }

            return(isIn);
        }
 protected override void BuildMessage(IEventArgs args)
 {
     builder.Key = FreeMessageConstant.PlaySound;
     if (null == pos)
     {
         if (play)
         {
             builder.Ks.Add(2);
             builder.Ins.Add(sound);
             builder.Bs.Add(self);
         }
         else
         {
         }
     }
     else
     {
         UnitPosition up = pos.Select(args);
         if (up != null)
         {
             builder.Ks.Add(3);
             builder.Fs.Add(up.GetX());
             builder.Fs.Add(up.GetY());
             builder.Fs.Add(up.GetZ());
             builder.Ins.Add(sound);
         }
     }
 }
Exemple #6
0
        public override string GetStyle(IEventArgs args, string key)
        {
            UnitPosition fromUp = from.Select(args);
            UnitPosition toUp   = to.Select(args);

            return(fromUp.GetX() + "_" + fromUp.GetY() + "_" + fromUp.GetZ() + SPLITER + toUp.GetX() + "_" + toUp.GetY() + "_" + toUp.GetZ() + SPLITER + FreeUtil.ReplaceVar(name, args) + SPLITER + FreeUtil.ReplaceFloat(scale, args) + SPLITER + FreeUtil.
                   ReplaceFloat(adjust, args));
        }
        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 #8
0
        private IPosSelector GetPos(UnitPosition up)
        {
            PosAssignSelector pas = new PosAssignSelector();

            pas.SetX(up.GetX().ToString());
            pas.SetY(up.GetY().ToString());
            pas.SetZ(up.GetZ().ToString());
            return(pas);
        }
Exemple #9
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);
        }
Exemple #10
0
        public virtual void Start(FreeRuleEventArgs args, FreeMoveEntity entity)
        {
            startTime = args.Rule.ServerTime;

            UnitPosition up = startPos.Select(args);

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

            StartMove(args, entity);
        }
 public virtual string GetXyz(IEventArgs args)
 {
     if (selector != null)
     {
         UnitPosition up = selector.Select(args);
         if (up != null)
         {
             return(up.GetX() + "," + up.GetY() + "," + up.GetZ());
         }
     }
     return(string.Empty);
 }
Exemple #12
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity p = GetPlayerEntity(args);

            UnitPosition up = pos.Select(args);

            if (up != null)
            {
                p.position.Value    = new UnityEngine.Vector3(up.GetX(), up.GetY(), up.GetZ());
                p.orientation.Yaw   = up.GetYaw();
                p.orientation.Pitch = FreeUtil.ReplaceFloat(pitch, args);

                p.latestAdjustCmd.SetPos(new UnityEngine.Vector3(up.GetX(), up.GetY(), up.GetZ()));
                p.latestAdjustCmd.ServerSeq = p.userCmdSeq.LastCmdSeq;

//                SimpleProto msg = FreePool.Allocate();
//                msg.Key = FreeMessageConstant.EntityMoveTo;
//                msg.Fs.Add(p.position.Value.x);
//                msg.Fs.Add(p.position.Value.y);
//                msg.Fs.Add(p.position.Value.z);
//                FreeMessageSender.SendMessage(p, msg);
            }
        }
Exemple #13
0
 private void Adjust(UnitPosition up, IEventArgs args)
 {
     up.SetX(up.GetX() + FreeUtil.ReplaceInt(x, args));
     up.SetY(up.GetY() + FreeUtil.ReplaceInt(y, args));
     up.SetZ(up.GetZ() + FreeUtil.ReplaceInt(z, args));
     if (!StringUtil.IsNullOrEmpty(pitch))
     {
         up.SetPitch(FreeUtil.ReplaceFloat(pitch, args));
     }
     if (!StringUtil.IsNullOrEmpty(yaw))
     {
         up.SetYaw(FreeUtil.ReplaceFloat(yaw, args));
     }
 }
Exemple #14
0
        public override void DoAction(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            float       realRadius = FreeUtil.ReplaceFloat(radius, args);
            float       realDamage = FreeUtil.ReplaceFloat(damage, args);
            EUIDeadType realType   = (EUIDeadType)FreeUtil.ReplaceInt(type, args);

            if (damagePara == null)
            {
                damagePara = new FloatPara("damage", realDamage);
                disPara    = new FloatPara("dis", 0f);
                typePara   = new StringPara("type", FreeUtil.ReplaceVar(type, args));
            }

            if (up != null)
            {
                var bombPos   = new Vector3(up.GetX(), up.GetY(), up.GetZ());
                var colliders = Physics.OverlapSphere(bombPos, realRadius,
                                                      UnityLayerManager.GetLayerMask(EUnityLayerName.Player) | UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast)
                                                      | UnityLayerManager.GetLayerMask(EUnityLayerName.Vehicle) | UnityLayerManager.GetLayerMask(EUnityLayerName.Glass));

                foreach (var collider in colliders)
                {
                    float trueDamage = CalculateBombDamage(collider.transform, bombPos, realDamage, realType);

                    if (Logger.IsDebugEnabled)
                    {
                        Logger.DebugFormat("Process {0}", collider.name);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Player))
                    {
                        HandlePlayer(collider, args, args.GameContext, trueDamage, bombPos);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.UserInputRaycast))
                    {
                        HandleFracturedObjects(collider.transform, bombPos, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Vehicle))
                    {
                        HandleVehicle(collider.transform, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Glass))
                    {
                        HandleGlass(collider.transform);
                    }
                }
            }
        }
        public override void DoAction(IEventArgs args)
        {
            FreeMoveEntity en = args.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            if (pos == null)
            {
                en.AddPosition();
                en.position.Value = new Vector3(FreeUtil.ReplaceFloat(x, args), FreeUtil.ReplaceFloat(y, args),
                                                FreeUtil.ReplaceFloat(z, args));
            }
            else
            {
                UnitPosition up = pos.Select(args);
                en.AddPosition();
                en.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
            }

            string realCat = FreeUtil.ReplaceVar(cat, args);

            if (realCat == null)
            {
                realCat = "";
            }
            string realValue = FreeUtil.ReplaceVar(value, args);

            if (realValue == null)
            {
                realValue = "";
            }
            en.AddFreeData(FreeUtil.ReplaceVar(key, args), null);
            en.freeData.Cat      = realCat;
            en.freeData.Value    = realValue;
            en.isFlagSyncNonSelf = true;

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

            if (distance > 0)
            {
                en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, distance);
            }

            if (!string.IsNullOrEmpty(lifeTime))
            {
                en.AddLifeTime(DateTime.Now, FreeUtil.ReplaceInt(lifeTime, args));
            }
        }
 public override void DoAction(IEventArgs args)
 {
     foreach (FreeMoveEntity freeMoveEntity in args.GameContext.freeMove.GetEntities())
     {
         if (freeMoveEntity.freeData.Key == FreeMove)
         {
             UnitPosition aimPos = targetPos.Select(args);
             if (!freeMoveEntity.hasFreeMoveController)
             {
                 freeMoveEntity.AddFreeMoveController();
             }
             freeMoveEntity.freeMoveController.FocusOnPosition =
                 new Vector3(aimPos.GetX(), aimPos.GetY(), aimPos.GetZ()).ShiftedToFixedVector3();
             freeMoveEntity.freeMoveController.ControllType = (byte)EFreeMoveControllType.FixFocusPos;
         }
     }
 }
Exemple #17
0
        public static UnitPosition GetAnglePosition(UnitPosition old,
                                                    double angle, float pitch, float distance, float height)
        {
            Vector3 dir = new Vector3();
            Vector3 end = new Vector3();

            AnglesToVector(angle, pitch, ref dir);
            Vector3DMA(new Vector3(old.GetX(), old.GetY(), old.GetZ()), distance, dir, ref end);

            UnitPosition up = new UnitPosition();

            up.SetX(end.x);
            up.SetY(end.y + height);
            up.SetZ(end.z);
            up.SetYaw(old.GetYaw());

            return(up);
        }
Exemple #18
0
        private UnitPosition GetPosition(IEventArgs args, UnitPosition old,
                                         double angle)
        {
            Vector3 dir = new Vector3();
            Vector3 end = new Vector3();

            AnglesToVector(angle, FreeUtil.ReplaceFloat(pitch, args), ref dir);
            Vector3DMA(new Vector3(old.GetX(), old.GetY(), old.GetZ()), FreeUtil.ReplaceFloat(distance, args), dir, ref end);

            UnitPosition up = new UnitPosition();

            up.SetX(end.x);
            up.SetY(end.y + FreeUtil.ReplaceFloat(height, args));
            up.SetZ(end.z);
            up.SetYaw(old.GetYaw());

            return(up);
        }
Exemple #19
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up       = pos.Select(args);
            UnitPosition targetUp = targetPos.Select(args);

            if (up != null && targetUp != null)
            {
                Vector3 dir = new Vector3();
                dir.x = targetUp.GetX() - up.GetX();
                dir.y = targetUp.GetY() - up.GetY();
                dir.z = targetUp.GetZ() - up.GetZ();

                dir = UnityPositionUtil.vectorToAngles(dir);

                double angle = FreeUtil.ReplaceDouble(this.angle, args);

                up = UnityPositionUtil.GetAnglePosition(up, angle + dir.x, 0, FreeUtil.ReplaceFloat(radius, args), 0);
            }

            return(up);
        }
Exemple #20
0
        protected override void BuildMessage(IEventArgs args)
        {
            builder.Key = FreeMessageConstant.PlaySound;

            builder.Bs.Add(FreeUtil.ReplaceBool(stop, args));
            builder.Bs.Add(FreeUtil.ReplaceBool(loop, args));
            builder.Bs.Add(pos != null);

            builder.Ins.Add(FreeUtil.ReplaceInt(id, args));

            if (!string.IsNullOrEmpty(entity))
            {
                foreach (FreeMoveEntity freeMoveEntity in args.GameContext.freeMove.GetEntities())
                {
                    if (freeMoveEntity.freeData.Key == entity)
                    {
                        builder.Ins.Add(freeMoveEntity.entityKey.Value.EntityId);
                    }
                }
            }

            if (key != null)
            {
                builder.Ss.Add(FreeUtil.ReplaceVar(key, args));
            }
            else
            {
                builder.Ss.Add("");
            }


            if (pos != null)
            {
                UnitPosition up = pos.Select(args);
                builder.Fs.Add(up.GetX());
                builder.Fs.Add(up.GetY());
                builder.Fs.Add(up.GetZ());
            }
        }
        protected override void BuildMessage(IEventArgs args)
        {
            this.scope = "4";

            builder.Key = FreeMessageConstant.PoisonCircle;
            builder.Ks.Add(0);

            UnitPosition from = fromPos.Select(args);

            builder.Fs.Add(from.GetX());
            builder.Fs.Add(from.GetY());

            UnitPosition to = toPos.Select(args);

            builder.Fs.Add(to.GetX());
            builder.Fs.Add(to.GetY());

            builder.Fs.Add(FreeUtil.ReplaceFloat(fromRadius, args));
            builder.Fs.Add(FreeUtil.ReplaceFloat(toRadius, args));
            builder.Ins.Add(FreeUtil.ReplaceInt(fromWaitTime, args));
            builder.Ins.Add(FreeUtil.ReplaceInt(fromMoveTime, args));
        }
Exemple #22
0
 protected override void BuildMessage(IEventArgs args)
 {
     builder.Key = 61;
     if (StringUtil.IsNullOrEmpty(key))
     {
         builder.Ss.Add(string.Empty);
     }
     else
     {
         builder.Ss.Add(FreeUtil.ReplaceVar(key, args));
     }
     builder.Ks.Add(FreeUtil.ReplaceInt(time.ToString(), args));
     if (pos != null)
     {
         UnitPosition up = pos.Select(args);
         if (up != null)
         {
             builder.Fs.Add(up.GetX());
             builder.Fs.Add(up.GetY());
             builder.Fs.Add(up.GetZ());
         }
     }
 }
        public void Start(FreeRuleEventArgs args, FreeMoveEntity entity)
        {
            UnitPosition up = startPos.Select(args);

            entity.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
        }
Exemple #24
0
 public static Vector3 ToVector3(UnitPosition up)
 {
     return(new Vector3(up.GetX(), up.GetY(), up.GetZ()));
 }
Exemple #25
0
 public static void SetUnitPositionToPlayer(PlayerEntity player, UnitPosition up)
 {
     player.position.Value    = new Vector3(up.GetX(), up.GetY(), up.GetZ());
     player.orientation.Yaw   = up.GetYaw();
     player.orientation.Pitch = up.GetPitch();
 }
Exemple #26
0
 public static void SetUnitPositionToEntity(PositionComponent position, UnitPosition up)
 {
     position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
 }