GameFramework.ProtoHelper.DecodePosition2D C# (CSharp) Method

DecodePosition2D() public static method

public static DecodePosition2D ( ulong v, float &x, float &y ) : void
v ulong
x float
y float
return void
        public static void DecodePosition2D(ulong v, out float x, out float y)
        {
            ulong vx = (v & 0x1ffff);
              ulong vy = ((v & 0x3fffe0000)>>17);
              x = DecodeFloat((int)vx);
              y = DecodeFloat((int)vy);
        }

Usage Example

        internal static void Execute(object msg, User user)
        {
            Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos;

            if (move_msg == null)
            {
                return;
            }
            EntityInfo charactor = user.Info;

            if (charactor == null)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name);
                return;
            }
            ///
            if (charactor.GetAIEnable())
            {
                float tx, tz;
                ProtoHelper.DecodePosition2D(move_msg.target_pos, out tx, out tz);
                ScriptRuntime.Vector3 pos = new ScriptRuntime.Vector3(tx, 0, tz);

                MovementStateInfo msi = charactor.GetMovementStateInfo();
                msi.IsMoving       = true;
                msi.TargetPosition = pos;
                float dir = Geometry.GetYRadian(msi.GetPosition3D(), pos);
                msi.SetFaceDir(dir);
                msi.SetMoveDir(dir);

                Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(charactor);
                if (null != npcMoveBuilder)
                {
                    Scene scene = user.OwnRoom.ActiveScene;
                    if (null != scene)
                    {
                        scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcMove, npcMoveBuilder);
                    }
                }
            }
        }