Exemplo n.º 1
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 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);
         }
     }
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            Vector3 fromV = UnityPositionUtil.ToVector3(up);

            Vector3 toV = new Vector3(up.GetX(), -10000, up.GetZ());

            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 (hited)
            {
                if (SingletonManager.Get <MapConfigManager>().InWater(new Vector3(hitInfo.point.x,
                                                                                  hitInfo.point.y - 0.1f, hitInfo.point.z)))
                {
                    hitInfo.point = new Vector3(fromV.x, hitInfo.point.y - waterDelta, fromV.z);
                }

                //Debug.LogFormat("hit {0},{1},{2}", hitInfo.point.x, hitInfo.point.y, hitInfo.point.z);

                return(UnityPositionUtil.FromVector(hitInfo.point));
            }

            return(up);
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        protected override void BuildMessage(IEventArgs args)
        {
            this.scope = "4";

            builder.Key = FreeMessageConstant.PoisonCircle;
            UnitPosition from = pos.Select(args);

            builder.Ks.Add(1);
            builder.Fs.Add(from.GetX());
            builder.Fs.Add(from.GetZ());

            builder.Ins.Add(FreeUtil.ReplaceInt(radius, args));
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 15
0
        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));
            }
        }
Exemplo n.º 16
0
 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;
         }
     }
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 21
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);
            }
        }
Exemplo n.º 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());
         }
     }
 }
Exemplo n.º 23
0
        public void Start(FreeRuleEventArgs args, FreeMoveEntity entity)
        {
            UnitPosition up = startPos.Select(args);

            entity.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
        }
Exemplo n.º 24
0
 public static Vector3 ToVector3(UnitPosition up)
 {
     return(new Vector3(up.GetX(), up.GetY(), up.GetZ()));
 }
Exemplo n.º 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();
 }
Exemplo n.º 26
0
 public static void SetUnitPositionToEntity(PositionComponent position, UnitPosition up)
 {
     position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
 }