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


C# NetIncomingMessage.ReadUInt16方法代码示例

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


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

示例1: Read

 protected override void Read(NetIncomingMessage message)
 {
     x = message.ReadFloat();
     y = message.ReadFloat();
     rotation = message.ReadUInt16().FromNetworkRotation() * (180f / (float)Math.PI);
     type = message.ReadByte();
 }
开发者ID:Rohansi,项目名称:Programe,代码行数:7,代码来源:NetAsteroid.cs

示例2: Read

 public override void Read(NetIncomingMessage msg)
 {
     Id = msg.ReadUInt16();
     int count = msg.ReadInt32();
     for(int i = 0; i < count; ++i)
         Cards.Add(msg.ReadString());
 }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:7,代码来源:WinnerPicked.cs

示例3: readBytes

 public static void readBytes(NetIncomingMessage data, ClientSprite cs)
 {
     data.ReadByte();
     cs.ID = data.ReadUInt32();
     cs.SpriteID = (SpriteIDs)data.ReadUInt16();
     cs.Position = new Microsoft.Xna.Framework.Vector2(data.ReadFloat(),data.ReadFloat());
     cs.Rotation = data.ReadFloat();
 }
开发者ID:Harlonlonmo,项目名称:Network-Game,代码行数:8,代码来源:ClientSpriteParser.cs

示例4: Read

 protected override void Read(NetIncomingMessage message)
 {
     Name = message.ReadString();
     X = message.ReadFloat();
     Y = message.ReadFloat();
     rotation = message.ReadUInt16().FromNetworkRotation() * (180f / (float)Math.PI);
     Health = message.ReadByte() / (float)byte.MaxValue;
 }
开发者ID:Rohansi,项目名称:Programe,代码行数:8,代码来源:NetShip.cs

示例5: Read

 protected override void Read(NetIncomingMessage message)
 {
     var length = message.ReadUInt16();
     Program = new short[length];
     for (var i = 0; i < length; i++)
     {
         Program[i] = message.ReadInt16();
     }
 }
开发者ID:Rohansi,项目名称:Programe,代码行数:9,代码来源:Upload.cs

示例6: Read

        protected override void Read(NetIncomingMessage message)
        {
            Items.Clear();

            var count = message.ReadUInt16();
            for (var i = 0; i < count; i++)
            {
                Items.Add(NetObject.ReadFromMessage(message));
            }
        }
开发者ID:Rohansi,项目名称:Programe,代码行数:10,代码来源:Objects.cs

示例7: HandleEntityComponentNetworkMessage

 /// <summary>
 /// Handles an incoming entity component message
 /// </summary>
 /// <param name="message">Raw network message</param>
 /// <returns>An IncomingEntityComponentMessage object</returns>
 public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
 {
     var componentFamily = (ComponentFamily) message.ReadByte();
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return new IncomingEntityComponentMessage(componentFamily, messageParams);
 }
开发者ID:Tri125,项目名称:space-station-14,代码行数:60,代码来源:EntityNetworkManager.cs

示例8: OnAdvancedNetworkMessage

 public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
 {
     if (msg.ReadByte() == 0)
     {
         this.lxLoot = new List<PreSeededLoot>();
         byte byCount = msg.ReadByte();
         for (int i = 0; i < (int)byCount; i++)
         {
             this.lxLoot.Add(new PreSeededLoot(msg.ReadUInt16(), (ItemCodex.ItemTypes)msg.ReadInt32(), new Vector2(msg.ReadFloat(), msg.ReadFloat())));
         }
     }
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:12,代码来源:GigaSlimeMemoryBattleBagman.cs

示例9: Read

        public override void Read(NetIncomingMessage msg)
        {
            int count = msg.ReadInt32();
            for(int i = 0; i < count; ++i)
            {
                ushort uid = msg.ReadUInt16();
                List<string> cards = new List<string>();

                int cardCount = msg.ReadInt32();
                for(int j = 0; j < cardCount; ++j)
                    cards.Add(msg.ReadString());

                Options.Add(new Tuple<ushort, List<string>>(uid, cards));
            }
        }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:15,代码来源:InitSelectionScreen.cs

示例10: Get

        public static Packet Get(NetIncomingMessage message)
        {
            var packetId = message.ReadUInt16();
            var pdata = PacketFactory.GetPacketType(packetId);

            var newPacket = (Packet)Activator
                .CreateInstance(pdata.PacketType);

            if (newPacket != null)
            {
                Bitstream stream = new Bitstream(message);
                newPacket.Deserialize(stream);
                return newPacket;
            }

            //TODO
            return null;
        }
开发者ID:jhlllnd,项目名称:Asgard,代码行数:18,代码来源:Packet.cs

示例11: HandleData

        public override void HandleData(NetIncomingMessage msg)
        {
            NetEntityType Type;
            ushort ID;
            Vector3 Position;
            Vector3 Velocity;
            Quaternion Orientation;
            NetMsgType datatype = (NetMsgType)msg.ReadByte();
            switch (datatype)
            {
                case NetMsgType.Chat:
                    Console.WriteLine(msg.ReadString());
                    break;
                case NetMsgType.CreateOnClient:
                    #region CreateOnClient
                    Type = (NetEntityType)msg.ReadByte();
                    ID = msg.ReadUInt16();
                    Position = new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat());
                    Orientation = new Quaternion(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat());
                    ushort Resource;
                    long OwnerID;

                    //DEBUG
                    if (Type == NetEntityType.Ship)
                    {
                        int[] shipWeapons = null;
                        var shipNose = msg.ReadInt32();
                        var shipCore = msg.ReadInt32();
                        var shipTail = msg.ReadInt32();
                        int weaponLength = msg.ReadInt32();
                        if (weaponLength > 0)
                        {
                            shipWeapons = new int[weaponLength];
                            for (int i = 0; i < weaponLength; i++)
                                shipWeapons[i] = msg.ReadInt32();
                        }
                        Resource = 0;
                        OwnerID = msg.ReadInt64();
                        var shipData = new ShipData(shipNose, shipCore, shipTail);
                        WeaponsFromData(shipData, shipWeapons);
                        var ship = new ShipObj(MobileFortressClient.Game, Position, Orientation, shipData);
                        ship.ID = ID;
                        if (OwnerID == Network.Client.UniqueIdentifier)
                        {
                            Network.JoinedGame = true;
                            Camera.Setup(MobileFortressClient.Game, ship, new Vector3(0, 2f, 6f));
                            var HUD = new ShipHUD();
                            if (shipWeapons != null)
                            {
                                for (int i = 0; i < shipWeapons.Length; i++)
                                {
                                    HUD.MakeAmmoIndicator(shipWeapons[i]);
                                }
                            }
                            MenuManager.Menu = HUD;
                        }
                    }
                    else
                    {
                        Resource = msg.ReadUInt16();
                        if (Type == NetEntityType.Building)
                        {
                            new Building(Position, Resource);
                        }
                        else if (Type == NetEntityType.Missile)
                        {
                            var obj = new Rocket(MobileFortressClient.Game, Resource, Position, Orientation);
                            obj.ID = ID;
                        }
                        else
                        {
                            var obj = new PhysicsObj(MobileFortressClient.Game, Position, Orientation, Resource);
                            obj.ID = ID;
                        }
                    }
                    #endregion
                    break;
                case NetMsgType.MapLoading:
                    #region MapLoading
                    if (msg.ReadByte() == 0)
                    {
                        var Seed = msg.ReadInt32();
                        var Power = msg.ReadInt32();
                        var Roughness = msg.ReadFloat();
                        Sector.Redria.Terrain.Terrain = new Heightmap(Seed, Power, Roughness);
                    }
                    else
                    {
                        var terrain = Sector.Redria.Terrain.Terrain;
                        int alterations = msg.ReadInt32();
                        Console.WriteLine(alterations + " Recieved Alterations.");
                        for (int i = 0; i < alterations; i++)
                        {
                            Rectangle flattenedArea = new Rectangle(msg.ReadInt32(),
                                msg.ReadInt32(), msg.ReadInt32(), msg.ReadInt32());
                            terrain.FlattenArea(flattenedArea);

                        }
                        terrain.Graphics.ResetVertexBuffer();

//.........这里部分代码省略.........
开发者ID:Aryn,项目名称:Mobile-Fortress,代码行数:101,代码来源:DataManager.cs

示例12: OnAdvancedNetworkMessage

 public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
 {
     if (msg.ReadByte() == 0)
     {
         FlagCodex.FlagID enFlag = (FlagCodex.FlagID)msg.ReadUInt16();
         this.HandleFlagTrigger(enFlag);
     }
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:8,代码来源:NPC_Naniva.cs

示例13: Read

 public virtual NetworkMessage Read(NetIncomingMessage msgIn)
 {
     type = (NetworkMessageType)msgIn.ReadUInt16();
     return this;
 }
开发者ID:massdriver,项目名称:FreeUniverse,代码行数:5,代码来源:NetworkMessage.cs

示例14: HandleRegisterHost

        private void HandleRegisterHost(NetIncomingMessage inc)
        {
            var id = inc.ReadInt64();
            var name = inc.ReadString();
            var population = inc.ReadUInt16();
            var maxPopulation = inc.ReadUInt16();
            var guid = inc.ReadString();
            var endpoint = inc.ReadIPEndpoint();
            var game = inc.ReadInt32();

            //if (manager.Register(id, new Guid(guid)))
            {
                registeredHosts[id] = new Object[]
                {
                    endpoint,
                    inc.SenderEndpoint,
                    name,
                    population,
                    maxPopulation,
                    NetTime.Now,
                    game
                };
            }
        }
开发者ID:imGoose,项目名称:SkyrimOnline,代码行数:24,代码来源:Program.cs

示例15: HandleDataMessage

        private void HandleDataMessage(NetIncomingMessage incomingMessage)
        {
            if (IsAuthenticated)
            {
                //incomingMessage.Decrypt(cryptoAlgorithm);
            }

            var p = incomingMessage.ReadProtocol();
            ushort messageType = incomingMessage.ReadUInt16();

            //Trace.WriteLine("Received " + ((CustomMessageType)messageType).ToString() + ".");

            var protocol = Protocols.Where(x => x.Equals(p)).First();

            var mHandlers = GetHandlers(protocol, messageType);
            var message = protocol.Create(messageType);
            message.ReadPayload(incomingMessage);

            if (OnMessageReceived != null)
                OnMessageReceived(null, new MessageEventArgs(this, message));

            if (mHandlers != null)
            {
                for (int n = 0; n < mHandlers.Count; ++n)
                    mHandlers[n](new MessageEventArgs(this, message));
            }
        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:27,代码来源:NetworkPeer.cs


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