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


C# NetPeer.SendMessage方法代码示例

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


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

示例1: checkForStatusUpdate

        public void checkForStatusUpdate(NetPeer netPeer, NetConnection connection, int team)
        {
            if (AmountChanged && ((team == Player.Me.Team && timeSinceStatusUpdate >= statusUpdateDelay) || Depleted))
            {
                timeSinceStatusUpdate = 0f;
                AmountChanged = false;

                NetOutgoingMessage msg = netPeer.CreateMessage();
                msg.Write(MessageID.RESOURCE_STATUS_UPDATE);
                msg.Write(ID);
                msg.Write((short)Amount);
                netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
            }
        }
开发者ID:nubington,项目名称:rts,代码行数:14,代码来源:Resource.cs

示例2: CheckForStatusUpdate

        public void CheckForStatusUpdate(GameTime gameTime, NetPeer netPeer, NetConnection connection)
        {
            timeSinceStatusUpdate += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (timeSinceStatusUpdate >= statusUpdateDelay)
            {
                timeSinceStatusUpdate = 0f;

                if (Team == Player.Me.Team)
                {
                    NetOutgoingMessage msg = netPeer.CreateMessage();
                    msg.Write(MessageID.UNIT_STATUS_UPDATE);
                    msg.Write(ID);
                    msg.Write(Team);
                    msg.Write((short)Hp);
                    msg.Write(centerPoint.X);
                    msg.Write(centerPoint.Y);
                    msg.Write(Rotation);
                    msg.Write(IsIdle);

                    // send current command ID, -1 if none
                    if (Commands.Count > 0)
                        msg.Write(Commands[0].ID);
                    else
                        msg.Write((short)-1);

                    // send cargoAmount, 0 if not worker
                    WorkerNublet worker = this as WorkerNublet;
                    if (worker != null)
                        msg.Write(worker.CargoAmount);
                    else
                        msg.Write((short)0);

                    netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
                }
                else if (HpChanged)
                {
                    HpChanged = false;

                    NetOutgoingMessage msg = netPeer.CreateMessage();
                    msg.Write(MessageID.UNIT_HP_UPDATE);
                    msg.Write(ID);
                    msg.Write(Team);
                    msg.Write((short)Hp);
                    netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
                }
            }
        }
开发者ID:nubington,项目名称:rts,代码行数:48,代码来源:Unit.cs

示例3: Send

 private void Send(NetPeer peer, NetConnection destination, NetDeliveryMethod method)
 {
     NetOutgoingMessage nom = peer.CreateMessage(InitialMessageSize());
     nom.Write(this.GetType().FullName);
     this.WriteData(nom);
     peer.SendMessage(nom, destination, method);
 }
开发者ID:CloneDeath,项目名称:Xanatos,代码行数:7,代码来源:Message.cs

示例4: SendMessage

 public static void SendMessage(NetPeer peer, NetworkMessageType networkMessageType, int data, NetConnection recipient)
 {
     NetOutgoingMessage message = peer.CreateMessage();
     message.Write((byte)networkMessageType);
     message.Write(data, 32);
     peer.SendMessage(message, recipient, NetDeliveryMethod.ReliableUnordered);
 }
开发者ID:JOCP9733,项目名称:tank,代码行数:7,代码来源:NetUtil.cs

示例5: SendMCS

        public static void SendMCS()
        {
            Console.WriteLine("Enter Port: ");
            int port = int.Parse(Console.ReadLine());

            NetPeerConfiguration config = new NetPeerConfiguration("InduZtry");
            config.Port = port;
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.EnableMessageType(NetIncomingMessageType.Data);
            //config.EnableUPnP = true;
            server = new NetPeer(config);
            server.Start();
            //Console.WriteLine(server.UPnP.Status);
            //server.UPnP.ForwardPort(port, "InduZtry");
            //Console.WriteLine(server.UPnP.Status);
            //Console.WriteLine("UPnP IP: " + server.UPnP.GetExternalIP());

            Thread t = new Thread(RecvMCS);
            t.IsBackground = true;
            t.Start();

            message = "NULL";

            while(true) {
                Thread.Sleep(10);
                if(recipient != null) {
                    NetOutgoingMessage sendMsg = server.CreateMessage();
                    sendMsg.Write(message);
                    server.SendMessage(sendMsg, recipient, NetDeliveryMethod.ReliableOrdered);
                }
            }
        }
开发者ID:RegrowthStudios,项目名称:VoxelRTS,代码行数:32,代码来源:Program.cs

示例6: CheckForStatusUpdate

        public void CheckForStatusUpdate(GameTime gameTime, NetPeer netPeer, NetConnection connection)
        {
            timeSinceStatusUpdate += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (HpChanged && timeSinceStatusUpdate >= statusUpdateDelay)
            {
                timeSinceStatusUpdate = 0f;
                HpChanged = false;

                NetOutgoingMessage msg = netPeer.CreateMessage();
                msg.Write(MessageID.STRUCTURE_STATUS_UPDATE);
                msg.Write(ID);
                msg.Write(Team);
                msg.Write((short)Hp);
                netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
            }
        }
开发者ID:nubington,项目名称:rts,代码行数:17,代码来源:Structure.cs


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