/// <summary> /// 同步小怪的目标 /// </summary> /// <param name="hurt"></param> /// <param name="id"></param> /// <param name="listNum"></param> public void SendEnemyTargetMsg(string ip, int id, int listNum) { byte[] by = EnemyTargetMessage.GetBytes( new EnemyTargetMessage(ip, id, listNum)); NetworkMessage message = new NetworkMessage(63, NetworkTools.GetLocalIP(), by); byte[] bytes = NetworkMessage.GetBytes(message); SendMsg(RoomSingle.roomIP, NetworkConstent.UDPServerPort, bytes); }
public static byte[] GetBytes(EnemyTargetMessage t) { byte[] btype = BitConverter.GetBytes(t.enemyType); byte[] bnum = BitConverter.GetBytes(t.num); byte[] ipBytes = Encoding.UTF8.GetBytes(t.targetIP); byte[] bytes = new byte[ipBytes.Length + btype.Length + bnum.Length]; btype.CopyTo(bytes, 0); bnum.CopyTo(bytes, 4); ipBytes.CopyTo(bytes, 8); return(bytes); }