本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadVariableInt32方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadVariableInt32方法的具体用法?C# NetIncomingMessage.ReadVariableInt32怎么用?C# NetIncomingMessage.ReadVariableInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.ReadVariableInt32方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleProtocol
private static void HandleProtocol(NetIncomingMessage inc, byte packetheader, NetServer server)
{
switch ((PacketTypes.Headers) packetheader)
{
case PacketTypes.Headers.ReadyUpdate:
bool playerStatus = Convert.ToBoolean(inc.ReadString());
Player thePlayer = LookUpPlayer(inc.SenderConnection.RemoteUniqueIdentifier);
Console.WriteLine("Player {0} changed status to {1}", thePlayer.Name, playerStatus);
Players[inc.SenderConnection.RemoteUniqueIdentifier].ToggleReady();
NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte) PacketTypes.Headers.ReadyUpdate);
msg.Write(inc.SenderConnection.RemoteUniqueIdentifier);
msg.Write(playerStatus);
server.SendToAll(msg, NetDeliveryMethod.ReliableOrdered);
break;
case PacketTypes.Headers.LoggedIn:
string username = inc.ReadString();
Player newPlayer = NewPlayer(inc, server, username);
Console.WriteLine(Players.Count);
if (Players.Count == 0)
{
Console.WriteLine("Sending {0} host packet", newPlayer.Name);
NetOutgoingMessage hMessage = server.CreateMessage();
hMessage.Write((byte) PacketTypes.Headers.YouAreHost);
server.SendMessage(hMessage, inc.SenderConnection, NetDeliveryMethod.ReliableOrdered);
}
Players.Add(inc.SenderConnection.RemoteUniqueIdentifier, newPlayer);
Players[inc.SenderConnection.RemoteUniqueIdentifier].Connection = inc.SenderConnection;
break;
case PacketTypes.Headers.ChatSend:
if (Players[inc.SenderConnection.RemoteUniqueIdentifier].Name != _drawer)
{
NetOutgoingMessage chatMessageRelay = server.CreateMessage();
string chatM = inc.ReadString();
chatMessageRelay.Write((byte) PacketTypes.Headers.ChatReceive);
chatMessageRelay.Write(Players[inc.SenderConnection.RemoteUniqueIdentifier].Name);
chatMessageRelay.Write(chatM);
if (!_badwordList.Contains(chatM, StringComparer.OrdinalIgnoreCase))
{
server.SendToAll(chatMessageRelay, NetDeliveryMethod.ReliableOrdered);
}
if (String.Equals(chatM, _theWord, StringComparison.CurrentCultureIgnoreCase) & chatM != null)
{
NetOutgoingMessage someoneOne = server.CreateMessage();
someoneOne.Write((byte) PacketTypes.Headers.ChatReceive);
someoneOne.Write("Server");
someoneOne.Write(Players[inc.SenderConnection.RemoteUniqueIdentifier].Name
+ " has guessed the correct word being: " + _theWord);
server.SendToAll(someoneOne, NetDeliveryMethod.ReliableOrdered);
RoundTimer.Stop();
StartNewRound(server);
}
}
break;
case PacketTypes.Headers.PictureUpdate:
int r = inc.ReadVariableInt32();
int g = inc.ReadVariableInt32();
int b = inc.ReadVariableInt32();
int x = inc.ReadVariableInt32();
int y = inc.ReadVariableInt32();
int size = inc.ReadVariableInt32();
NetOutgoingMessage msgPicture = server.CreateMessage();
msgPicture.Write((byte) PacketTypes.Headers.PictureUpdate);
msgPicture.WriteVariableInt32(r);
msgPicture.WriteVariableInt32(g);
msgPicture.WriteVariableInt32(b);
msgPicture.WriteVariableInt32(x);
msgPicture.WriteVariableInt32(y);
msgPicture.WriteVariableInt32(size);
server.SendToAll(msgPicture, NetDeliveryMethod.ReliableOrdered);
break;
case PacketTypes.Headers.StartGame:
NetOutgoingMessage msgStart = server.CreateMessage();
msgStart.Write((byte) PacketTypes.Headers.StartGame);
server.SendToAll(msgStart, NetDeliveryMethod.ReliableOrdered);
RoundTimer.Enabled = true;
StartNewRound(server);
break;
case PacketTypes.Headers.DrawLine:
{
int r1 = inc.ReadVariableInt32();
int g1 = inc.ReadVariableInt32();
int b1 = inc.ReadVariableInt32();
int x1 = inc.ReadVariableInt32();
int y1 = inc.ReadVariableInt32();
int size1 = inc.ReadVariableInt32();
int x11 = inc.ReadVariableInt32();
int y11 = inc.ReadVariableInt32();
NetOutgoingMessage msgDrawLine = server.CreateMessage();
msgDrawLine.Write((byte) PacketTypes.Headers.DrawLine);
msgDrawLine.WriteVariableInt32(r1);
msgDrawLine.WriteVariableInt32(g1);
msgDrawLine.WriteVariableInt32(b1);
msgDrawLine.WriteVariableInt32(x1);
msgDrawLine.WriteVariableInt32(y1);
msgDrawLine.WriteVariableInt32(size1);
msgDrawLine.WriteVariableInt32(x11);
msgDrawLine.WriteVariableInt32(y11);
//.........这里部分代码省略.........