/// <summary> /// 客户端发送当前角色移动消息 /// </summary> /// <param name="role"></param> /// <param name="buffer"></param> private void OnWorldMapCurrRoleMove(Role role, byte[] buffer) { WorldMap_CurrRoleMoveProto proto = WorldMap_CurrRoleMoveProto.GetProto(role.SocketReceiveMS, buffer); //Console.WriteLine("我的服务器时间=" + proto.ServerTime); //Console.WriteLine("服 务器时间=" + DateTime.Now.ToUniversalTime().Ticks / 10000); List <Role> lst = GetRoleList(role.LastInWorldMapId); if (lst != null && lst.Count > 0) { for (int i = 0; i < lst.Count; i++) { if (lst[i].RoleId == role.RoleId) { continue; } WorldMap_OtherRoleMoveProto myProto = new WorldMap_OtherRoleMoveProto(); myProto.RoleId = role.RoleId; myProto.TargetPosX = proto.TargetPosX; myProto.TargetPosY = proto.TargetPosY; myProto.TargetPosZ = proto.TargetPosZ; myProto.ServerTime = proto.ServerTime; myProto.NeedTime = proto.NeedTime; lst[i].Client_Socket.SendMsg(myProto.ToArray(lst[i].SocketSendMS)); } } }
public static WorldMap_CurrRoleMoveProto GetProto(byte[] buffer, bool isChild = false) { WorldMap_CurrRoleMoveProto proto = new WorldMap_CurrRoleMoveProto(); MMO_MemoryStream ms = null; if (!isChild) { ms = GameEntry.Socket.SocketSendMS; } else { ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>(); } ms.SetLength(0); ms.Write(buffer, 0, buffer.Length); ms.Position = 0; proto.TargetPosX = ms.ReadFloat(); proto.TargetPosY = ms.ReadFloat(); proto.TargetPosZ = ms.ReadFloat(); proto.ServerTime = ms.ReadLong(); proto.NeedTime = ms.ReadInt(); if (isChild) { GameEntry.Pool.EnqueueClassObject(ms); } return(proto); }
public static WorldMap_CurrRoleMoveProto GetProto(byte[] buffer) { WorldMap_CurrRoleMoveProto proto = new WorldMap_CurrRoleMoveProto(); using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer)) { proto.TargetPosX = ms.ReadFloat(); proto.TargetPosY = ms.ReadFloat(); proto.TargetPosZ = ms.ReadFloat(); proto.ServerTime = ms.ReadLong(); proto.NeedTime = ms.ReadInt(); } return(proto); }
public static WorldMap_CurrRoleMoveProto GetProto(MMO_MemoryStream ms, byte[] buffer) { WorldMap_CurrRoleMoveProto proto = new WorldMap_CurrRoleMoveProto(); ms.SetLength(0); ms.Write(buffer, 0, buffer.Length); ms.Position = 0; proto.TargetPosX = ms.ReadFloat(); proto.TargetPosY = ms.ReadFloat(); proto.TargetPosZ = ms.ReadFloat(); proto.ServerTime = ms.ReadLong(); proto.NeedTime = ms.ReadInt(); return(proto); }