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


C# NetIncomingMessage.ReadTime方法代码示例

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


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

示例1: DataProcessing

 // TODO: Merge opcodes for move direction, something like that: Move(LookDirection)
 void DataProcessing(NetIncomingMessage message, ref Client client)
 {
     switch (message.ReadByte())
     {
         case (byte)MessageType.ClientMessage.NeedMap:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Need map ! Let's give it to him :)");
             ReceiveNeedMap(client);
             break;
         case (byte)MessageType.ClientMessage.MapSelection:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Has selected a map to play ! :)");
             ReceiveMapSelection(client, message.ReadString());
             break;
         case (byte)MessageType.ClientMessage.Credentials:
             ReceiveCredentials(client, message.ReadString(), message.ReadString());
             break;
         case (byte)MessageType.ClientMessage.Ready:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Ready message !");
             ReceiveReady(client, message.ReadBoolean());
             break;
         case (byte)MessageType.ClientMessage.WantToStartGame:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] WantToStartGame message !");
             ReceiveWantToStartGame();
             break;
         case (byte)MessageType.ClientMessage.HasMap:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] HasMap message !");
             ReceiveHasMap(client);
             break;
         case (byte)MessageType.ClientMessage.MoveDown:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move down !");
             ReceiveMovePlayer(client, LookDirection.Down);
             break;
         case (byte)MessageType.ClientMessage.MoveLeft:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move left !");
             ReceiveMovePlayer(client, LookDirection.Left);
             break;
         case (byte)MessageType.ClientMessage.MoveRight:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move right !");
             ReceiveMovePlayer(client, LookDirection.Right);
             break;
         case (byte)MessageType.ClientMessage.MoveUp:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move up !");
             ReceiveMovePlayer(client, LookDirection.Up);
             break;
         case (byte)MessageType.ClientMessage.Standing:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to stay here !");
             ReceiveMovePlayer(client, LookDirection.Idle, message.ReadTime(client.ClientConnection, true));
             break;
         case (byte)MessageType.ClientMessage.PlaceBomb:
             Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to place bomb !");
             ReceiveBombPlacing(client);
             break;
     }
 }
开发者ID:Noxalus,项目名称:Final-Bomber,代码行数:54,代码来源:DataProcessing.cs

示例2: ReadPlayerState

        private void ReadPlayerState(NetIncomingMessage msg, Player p)
        {
            bool alive = msg.ReadBoolean();
            if (alive)
            {
                float px = msg.ReadFloat();
                float py = msg.ReadFloat();
                bool moving = msg.ReadBoolean();
                Direction direction = (Direction)msg.ReadByte();
                float speed = msg.ReadFloat();

                // player state
                p.UpdateFromNetwork(px, py, moving, direction, speed);

                // powerups
                int powerupsCount = (int)Powerups.Count;
                for (int i = 0; i < powerupsCount; ++i)
                {
                    bool hasPower = msg.ReadBoolean();
                    if (hasPower)
                    {
                        int count = msg.ReadByte();
                        p.powerups.SetCount(i, count);
                    }
                    else
                    {
                        p.powerups.SetCount(i, 0);
                    }
                }

                // diseases
                int diseasesCount = DiseaseList.diseaseArray.Length;
                for (int i = 0; i < diseasesCount; ++i)
                {
                    bool infected = msg.ReadBoolean();
                    if (infected)
                    {
                        float remains = (float)(msg.ReadTime(false) - NetTime.Now);
                        p.diseases.TryInfect(i);
                        p.diseases.SetInfectedRemains(i, remains);
                    }
                    else
                    {
                        p.diseases.TryCure(i);
                    }
                }
            }
            else if (p.IsAlive)
            {
                Field.KillPlayer(p);
            }

            Bomb[] bombs = p.bombs.array;
            for (int i = 0; i < bombs.Length; ++i)
            {
                ReadBombState(msg, p, bombs[i]);
            }
        }
开发者ID:bbqchickenrobot,项目名称:atomic-bomberman-xna,代码行数:58,代码来源:GameControllerNetwork.cs

示例3: ReadBombState

        private void ReadBombState(NetIncomingMessage msg, Player p, Bomb b)
        {
            bool active = msg.ReadBoolean();
            if (active)
            {
                float remains = (float)(msg.ReadTime(false) - NetTime.Now);
                float px = msg.ReadFloat();
                float py = msg.ReadFloat();
                Direction dir = (Direction)msg.ReadByte();
                float speed = msg.ReadFloat();
                bool jelly = msg.ReadBoolean();
                bool trigger = msg.ReadBoolean();

                if (!b.isActive)
                {
                    b.player = p;
                    b.Activate();
                    game.Field.SetBomb(b);
                }

                b.timeRemains = remains;
                b.SetPos(px, py);
                b.SetSpeed(speed);
                b.SetJelly(jelly);
                b.SetTrigger(trigger);
                // TODO: jelly & trigger
            }
            else if (b.isActive)
            {
                b.Deactivate();
                b.RemoveFromField();
            }
        }
开发者ID:bbqchickenrobot,项目名称:atomic-bomberman-xna,代码行数:33,代码来源:GameControllerNetwork.cs


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