Пример #1
0
        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()));
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
            }
        }
Пример #5
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();
 }