本文整理匯總了C#中System.IO.BinaryWriter.WriteNetwork方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryWriter.WriteNetwork方法的具體用法?C# BinaryWriter.WriteNetwork怎麽用?C# BinaryWriter.WriteNetwork使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteNetwork方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateHandshakePacket
public static byte[] CreateHandshakePacket(string username)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Handshake);
writer.WriteNetwork(username);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例2: CreateDisconnectPacket
public static byte[] CreateDisconnectPacket(string message)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Disconnect);
writer.WriteNetwork(message);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例3: CreateArmAnimationPacket
public static byte[] CreateArmAnimationPacket(int id, bool animate)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.ArmAnimation);
writer.WriteNetwork(id);
writer.Write(animate);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例4: CreatePlayerPositionPacket
public static byte[] CreatePlayerPositionPacket(double x, double y, double stance, double z, bool ground)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerPosition);
writer.WriteNetwork(x);
writer.WriteNetwork(y);
writer.WriteNetwork(stance);
writer.WriteNetwork(z);
writer.Write(ground);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例5: CreatePlayerLookPacket
public static byte[] CreatePlayerLookPacket(float yaw, float pitch, bool ground)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerLook);
writer.WriteNetwork(yaw);
writer.WriteNetwork(pitch);
writer.Write(ground);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例6: CreatePlayerInventoryPacket
public static byte[] CreatePlayerInventoryPacket(MCInventoryType type, MCItem[] items)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerInventory);
writer.WriteNetwork((int)type);
writer.WriteNetwork((short)items.Length);
foreach (MCItem item in items)
{
writer.WriteNetwork((short)item.Type);
if (item.Type != MCBlockType.None)
{
writer.Write(item.Count);
writer.WriteNetwork(item.Health);
}
}
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例7: CreatePlayerHoldingPacket
public static byte[] CreatePlayerHoldingPacket(int id, short item)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.HoldSwitch);
writer.WriteNetwork(id);
writer.WriteNetwork(item);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例8: CreatePlayerDiggingPacket
public static byte[] CreatePlayerDiggingPacket(byte status, int x, byte y, int z, byte face)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.BlockDig);
writer.Write(status);
writer.WriteNetwork(x);
writer.Write(y);
writer.WriteNetwork(z);
writer.Write(face);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例9: CreateLoginPacket
public static byte[] CreateLoginPacket(string username, string password)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Login);
writer.WriteNetwork(2); // Protocol version
writer.WriteNetwork(username);
writer.WriteNetwork(password);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}