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


C# NetIncomingMessage.ReadTransferType方法代码示例

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


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

示例1: ReadData

 void ReadData(NetIncomingMessage msg)
 {
     var type = msg.ReadTransferType();
     switch (type)
     {
         case Helpers.TransferType.NewConnection: NewServerConnection(msg); break;
         case Helpers.TransferType.PlayerUpdate: UpdateOtherPlayer(msg); break;
         case Helpers.TransferType.ProjectileUpdate: UpdateProjectile(msg); break;
         case Helpers.TransferType.HealthUpdate:UpdateHealthBar(msg); break;
     }
 }
开发者ID:elefantstudio-se,项目名称:xna-lidgren-multiplayer-game,代码行数:11,代码来源:Game1.cs

示例2: GetMsgs

        /// <summary>
        /// Hämtar alla nya meddelanden, läggs i
        /// update-funktionen!
        /// </summary>
        public void GetMsgs()
        {
            if (internetConnection)
            {
                while ((im = client.ReadMessage()) != null)
                {
                    switch (im.MessageType)
                    {
                        case NetIncomingMessageType.DiscoveryResponse:
                            //Ansluter om server hittas
                            client.Connect(im.SenderEndpoint);
                            break;
                        case NetIncomingMessageType.Data:
                            //Undersöker vilken sorts meddelande som mottas
                            var type = im.ReadTransferType();
                            switch (type)
                            {
                                //Ny anslutning
                                case Constants.NewConnection:
                                    players = new OtherPlayer[Constants.MAXPLAYERS];
                                    Globals.players = players;
                                    player = Package.MsgToPlayer(im, device);
                                    Console.WriteLine("Constants.NewConnection:" + player.model);
                                    Globals.player = player;
                                    connected = true;
                                    break;

                                //Ngn annan disconnectade
                                case Constants.ClientDisconnect:
                                    Package.PlayerLeft(im, players);
                                    break;

                                //Spelaruppdatering
                                case Constants.PlayerUpdate:
                                    Package.ToOtherPlayers(im, players);
                                    break;

                                //Någon har skjutit
                                case Constants.HitSomeone:
                                    Int32 k = im.ReadInt32();
                                    Int32 shooter = im.ReadInt32();
                                    if (k == Globals.player.id)
                                    {
                                        Globals.player.GotHit(10, shooter);
                                    }
                                    break;

                                case Constants.Status:
                                    Int32 iii = im.ReadInt32();
                                    Int16 st = im.ReadInt16();
                                    if(Globals.players[iii] != null)
                                        Globals.players[iii].activity = st;
                                    break;
                                case Constants.RewardKiller:
                                    /*Int32 jj = im.ReadInt32();
                                    if (Globals.player.id == jj)
                                        Globals.player.killingspree = true;*/
                                    break;
                            }
                            break;
                    }
                    client.Recycle(im);
                }
            }
        }
开发者ID:andva,项目名称:Eulerian-ShootEmUp,代码行数:69,代码来源:NWClient.cs

示例3: HandleMsgs

        static void HandleMsgs()
        {
            while ((msg = server.ReadMessage()) != null)
            {
                switch (msg.MessageType)
                {
                    case NetIncomingMessageType.DiscoveryRequest:
                        // Server received a discovery request from a client;
                        server.SendDiscoveryResponse(null, msg.SenderEndpoint);
                        Console.WriteLine("Discovery request!");
                        break;
                    case NetIncomingMessageType.StatusChanged:
                        StatusChanged(msg);
                        break;
                    case NetIncomingMessageType.Data:

                        // broadcast this to all connections, except sender
                        var type = msg.ReadTransferType();
                        if (type == Constants.PlayerUpdate)
                        {
                            Brodcast(msg);
                        }
                        else if (type == Constants.ClientDisconnect)
                        {
                            PlayerLeft(msg);
                        }
                        else if (type == Constants.HitSomeone)
                        {
                            SendHit(msg);
                        }
                        else if (type == Constants.Status)
                        {
                            UpdateStatus(msg);
                        }
                        else if (type == Constants.RewardKiller)
                        {

                        }
                        break;
                }
                server.Recycle(msg);
            }
        }
开发者ID:andva,项目名称:Eulerian-ShootEmUp,代码行数:43,代码来源:Program.cs


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