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


C# NetworkMessage.PeekUInt16方法代码示例

本文整理汇总了C#中NetworkMessage.PeekUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkMessage.PeekUInt16方法的具体用法?C# NetworkMessage.PeekUInt16怎么用?C# NetworkMessage.PeekUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkMessage的用法示例。


在下文中一共展示了NetworkMessage.PeekUInt16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseMessage

        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination, NetworkMessage outMsg)
        {
            if (msg.GetByte() != (byte)IncomingPacketType.TileUpdate)
                return false;

            Destination = destination;
            Type = IncomingPacketType.TileUpdate;
            outMsg.AddByte((byte)Type);

            Objects.Location pos = msg.GetLocation();
            outMsg.AddLocation(pos);

            ushort thingId = msg.PeekUInt16();

            if (thingId == 0xFF01)
            {
                outMsg.AddUInt16(msg.GetUInt16());
            }
            else
            {
                ParseTileDescription(msg, pos, outMsg);
                outMsg.AddUInt16(msg.GetUInt16());
            }

            return true;
        }
开发者ID:Xileck,项目名称:tibiaapi,代码行数:26,代码来源:TileUpdatePacket.cs

示例2: ParseFloorDescription

        protected bool ParseFloorDescription(NetworkMessage msg, int x, int y, int z, int width, int height, int offset, NetworkMessage outMsg)
        {
            ushort skipTiles;

            for (int nx = 0; nx < width; nx++)
            {
                for (int ny = 0; ny < height; ny++)
                {
                    if (m_skipTiles == 0)
                    {
                        ushort tileOpt = msg.PeekUInt16();
                        //Decide if we have to skip tiles
                        // or if it is a real tile
                        if (tileOpt >= 0xFF00)
                        {
                            skipTiles = msg.GetUInt16();
                            outMsg.AddUInt16(skipTiles);

                            m_skipTiles = (short)(skipTiles & 0xFF);
                        }
                        else
                        {
                            //real tile so read tile
                            Objects.Location pos = new Pokemon.Objects.Location(x + nx + offset, y + ny + offset, z);

                            if (!ParseTileDescription(msg, pos, outMsg))
                            {
                                return false;
                            }
                            //read skip tiles info
                            skipTiles = msg.GetUInt16();
                            outMsg.AddUInt16(skipTiles);

                            m_skipTiles = (short)(skipTiles & 0xFF);
                        }
                    }
                    //skipping tiles...
                    else
                    {
                        m_skipTiles--;
                    }
                }
            }
            return true;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:45,代码来源:MapPacket.cs

示例3: ParseTileDescription

        protected bool ParseTileDescription(NetworkMessage msg, Objects.Location pos, NetworkMessage outMsg)
        {
            int n = 0;
            bool ret = true;
            Tile tile = new Tile(Client, 0, pos);
            while (true)
            {
                ushort inspectTileId = msg.PeekUInt16();

                if (inspectTileId >= 0xFF00)
                {
                    //end of the tile
                    ret = true;
                    break;
                }
                else
                {
                    if (n > 10)
                    {
                        ret = false;
                        break;
                    }
                    //read tile things: items and creatures
                    ParseThing(msg, pos, tile, n, outMsg);
                }

                n++;
            }

            tiles.Add(tile);
            return ret;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:32,代码来源:MapPacket.cs


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