本文整理汇总了C#中UnityEngine.Networking.NetworkWriter.AsArray方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkWriter.AsArray方法的具体用法?C# NetworkWriter.AsArray怎么用?C# NetworkWriter.AsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Networking.NetworkWriter
的用法示例。
在下文中一共展示了NetworkWriter.AsArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostInternalMessage
private void PostInternalMessage(short msgType)
{
NetworkWriter networkWriter = new NetworkWriter();
networkWriter.StartMessage(msgType);
networkWriter.FinishMessage();
this.PostInternalMessage(networkWriter.AsArray(), 0);
}
示例2: Serialize
public static byte[] Serialize(INetMsg msg)
{
var networkWriter = new NetworkWriter();
uint index = GetMsgIndexFromType( msg.GetType() );
networkWriter.WritePackedUInt32( index );
((MessageBase)msg).Serialize(networkWriter);
return networkWriter.AsArray();
}
示例3: InvokeHandlerOnClient
internal void InvokeHandlerOnClient(short msgType, MessageBase msg, int channelId)
{
NetworkWriter writer = new NetworkWriter();
writer.StartMessage(msgType);
msg.Serialize(writer);
writer.FinishMessage();
this.InvokeBytesOnClient(writer.AsArray(), channelId);
}
示例4: SendWriter
public override bool SendWriter(NetworkWriter writer, int channelId)
{
return this.m_LocalServer.InvokeBytes(this, writer.AsArray(), (short) writer.AsArray().Length, channelId);
}
示例5: SendWriter
public override bool SendWriter(NetworkWriter writer, int channelId)
{
this.m_LocalClient.InvokeBytesOnClient(writer.AsArray(), channelId);
return true;
}
示例6: LockTileMessage
private byte[] LockTileMessage(World.Avatar avatar, byte tile)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.LockTile);
writer.Write(avatar != null ? avatar.id : -1);
writer.Write(tile);
return writer.AsArray();
}
示例7: SetWallMessage
private byte[] SetWallMessage(byte tile, bool wall)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.SetWall);
writer.Write(tile);
writer.Write(wall);
return writer.AsArray();
}
示例8: TileInChunksMessages
private byte[][] TileInChunksMessages(World world,
byte tile,
int size = 128)
{
int x = tile % 16;
int y = tile / 16;
Color[] colors = world.tileset.GetPixels(x * 32, y * 32, 32, 32);
byte[] bytes = colors.Select(c => world.ColorToPalette(c, true)).ToArray();
byte[] chunk;
int offset = 0;
var messages = new List<byte[]>();
while (bytes.Any())
{
chunk = bytes.Take(size).ToArray();
bytes = bytes.Skip(size).ToArray();
var writer = new NetworkWriter();
writer.Write((byte) Type.TileChunk);
writer.Write(tile);
writer.Write(offset);
writer.WriteBytesFull(CrunchBytes(chunk));
messages.Add(writer.AsArray());
offset += size;
}
return messages.ToArray();
}
示例9: PaletteEditMessage
private byte[] PaletteEditMessage(byte index)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.PaletteEdit);
writer.Write(index);
writer.Write((Color32) world.palette[index]);
return writer.AsArray();
}
示例10: ChatMessage
private byte[] ChatMessage(World.Avatar avatar, string message)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.Chat);
writer.Write(avatar.id);
writer.Write(message);
return writer.AsArray();
}
示例11: MoveAvatarMessage
private byte[] MoveAvatarMessage(World.Avatar avatar,
Vector2 destination)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.MoveAvatar);
writer.Write(avatar.id);
writer.Write(destination);
return writer.AsArray();
}
示例12: GiveAvatarMessage
private byte[] GiveAvatarMessage(World.Avatar avatar)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.GiveAvatar);
writer.Write(avatar.id);
return writer.AsArray();
}
示例13: ReplicateAvatarMessage
private byte[] ReplicateAvatarMessage(World.Avatar avatar)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.ReplicateAvatar);
writer.Write(avatar.id);
writer.Write(avatar.destination);
writer.Write(avatar.source);
return writer.AsArray();
}
示例14: SendWorld
private IEnumerator SendWorld(int connectionID, World world)
{
{
var writer = new NetworkWriter();
writer.Write((byte) Type.Tilemap);
writer.WriteBytesFull(world.tilemap);
Send(connectionID, writer.AsArray());
}
{
var writer = new NetworkWriter();
writer.Write((byte) Type.Palette);
for (int i = 0; i < 16; ++i) writer.Write((Color32) world.palette[i]);
Send(connectionID, writer.AsArray());
}
{
var writer = new NetworkWriter();
writer.Write((byte) Type.Walls);
writer.WriteBytesFull(world.walls.ToArray());
Send(connectionID, writer.AsArray());
}
foreach (var avatar in world.avatars)
{
Send(connectionID, ReplicateAvatarMessage(avatar));
if (avatar.id == connectionID)
{
Send(connectionID, GiveAvatarMessage(avatar));
}
else
{
Send(connectionID, AvatarInChunksMessages(world, avatar));
}
}
for (int i = 0; i < maxTiles; ++i)
{
yield return new WaitForSeconds(0.125f);
Send(connectionID, TileInChunksMessages(world, (byte) i));
}
}
示例15: SetTileMessage
private byte[] SetTileMessage(int location,
byte tile)
{
var writer = new NetworkWriter();
writer.Write((byte) Type.SetTile);
writer.Write(location);
writer.Write(tile);
return writer.AsArray();
}