当前位置: 首页>>代码示例>>C#>>正文


C# NetworkWriter.AsArray方法代码示例

本文整理汇总了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);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:LocalClient.cs

示例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();
 }
开发者ID:Zammy,项目名称:ProjectSpaceship,代码行数:8,代码来源:Messages.cs

示例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);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:LocalClient.cs

示例4: SendWriter

 public override bool SendWriter(NetworkWriter writer, int channelId)
 {
     return this.m_LocalServer.InvokeBytes(this, writer.AsArray(), (short) writer.AsArray().Length, channelId);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:4,代码来源:ULocalConnectionToServer.cs

示例5: SendWriter

 public override bool SendWriter(NetworkWriter writer, int channelId)
 {
     this.m_LocalClient.InvokeBytesOnClient(writer.AsArray(), channelId);
     return true;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:5,代码来源:ULocalConnectionToClient.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:9,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:9,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:33,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:9,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:9,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:10,代码来源:Test.cs

示例12: GiveAvatarMessage

    private byte[] GiveAvatarMessage(World.Avatar avatar)
    {
        var writer = new NetworkWriter();
        writer.Write((byte) Type.GiveAvatar);
        writer.Write(avatar.id);

        return writer.AsArray();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:8,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:10,代码来源:Test.cs

示例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));
        }
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:51,代码来源:Test.cs

示例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();
    }
开发者ID:Ragzouken,项目名称:smooltool,代码行数:10,代码来源:Test.cs


注:本文中的UnityEngine.Networking.NetworkWriter.AsArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。