本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ToString方法的具体用法?C# NetIncomingMessage.ToString怎么用?C# NetIncomingMessage.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnUpdate
protected override void OnUpdate(TimeSpan gameTime)
{
while((IncomeMessage = Client.ReadMessage()) != null)
{
switch(IncomeMessage.MessageType)
{
case NetIncomingMessageType.Error:
case NetIncomingMessageType.ErrorMessage:
throw new Exception(IncomeMessage.ToString());
case NetIncomingMessageType.Data:
ProcessMessage(IncomeMessage);
break;
}
}
}
示例2: HandleAGameMessage
//.........这里部分代码省略.........
break;
case "PART": //Remove a player
long UID_PART = msg.ReadInt64();
HandlePartMessage(UID_PART);
break;
case "INFO": //Recieved when server has completed sending all newbie initialization
break;
case "BULLET":
long UID_BULLET = msg.ReadInt64();
float xBULLET = msg.ReadFloat();
float yBULLET = msg.ReadFloat();
float BULLETangle = msg.ReadFloat();
Bullet b = new Bullet(UID_BULLET, BULLETangle, new Vector2f(xBULLET, yBULLET));
HandleBulletCreate(b, UID_BULLET);
break;
case "RESPAWN":
long UID_RESPAWN = msg.ReadInt64();
HandleRespawnMessage(UID_RESPAWN);
break;
case "COIN":
//long UID_COIN = msg.ReadInt64();
float xCOIN = msg.ReadFloat();
float yCOIN = msg.ReadFloat();
int countCOIN = msg.ReadInt32();
HandleCoinCreate(countCOIN, xCOIN, yCOIN);
break;
case "SWITCHWEAPON":
long UID_WEPSWITCH = msg.ReadInt64();
int WEAPONID = msg.ReadInt32();
HandleNetPlayerWeaponSwitch(UID_WEPSWITCH, WEAPONID);
break;
case "KILLER":
long UID_VICTIM = msg.ReadInt64();
long UID_KILLER = msg.ReadInt64();
HandleKillerMessage(UID_VICTIM, UID_KILLER);
break;
case "LOOT":
Console.WriteLine("LOOT Recieved");
int LOOTseed = msg.ReadInt32();
Console.WriteLine(LOOTseed);
Random rand = new Random(LOOTseed);
MainGame.dm.GameObjects.Add(new TreasureBox(new Vector2f(rand.Next(40, 1600), 180)));
break;
case "EMOTE":
long UID_EMOTE = msg.ReadInt64();
string EMOTE_TYPE = msg.ReadString();
MainGame.dm.GameObjects.Add(new EmoteBubble(EMOTE_TYPE, MainGame.dm.GetPlayerWithUID(UID_EMOTE))); ;
break;
case "BOMB":
long UID_EXPLOSIVE = msg.ReadInt64();
float xEXP = msg.ReadFloat();
float yEXP = msg.ReadFloat();
float EXPangle = msg.ReadFloat();
BombInstance bomb = new BombInstance(UID_EXPLOSIVE, EXPangle, new Vector2f(xEXP, yEXP));
HandleBombCreate(bomb, UID_EXPLOSIVE);
break;
case "TIME":
float TIME_MESSAGE = msg.ReadFloat();
HandleTimeMessage(TIME_MESSAGE);
break;
case "MODEL":
Console.WriteLine("Model");
long UID_MODEL = msg.ReadInt64();
string MODEL_STR = msg.ReadString();
Console.WriteLine(MODEL_STR);
HandleModel(UID_MODEL, MODEL_STR);
break;
case "GOLDCOUNT":
long UID_GOLDCOUNT = msg.ReadInt64();
int goldCount = msg.ReadInt32();
HandleGoldCountMessage(UID_GOLDCOUNT, goldCount);
break;
case "LANDMINE":
long UID_MINEOWNER = msg.ReadInt64();
float xMINE = msg.ReadFloat();
float yMINE = msg.ReadFloat();
int MINE_ID = msg.ReadInt32();
HandleLandMineMessage(UID_MINEOWNER, xMINE, yMINE, MINE_ID);
break;
case "LANDMINE_TRIGGER":
int LANDMINEID = msg.ReadInt32();
HandleLandMineTriggerMessage(LANDMINEID);
break;
case "GENERATOR":
long UID_GENOWNER = msg.ReadInt64();
float xGEN = msg.ReadFloat();
float yGEN = msg.ReadFloat();
int type = msg.ReadInt32();
DateTime when = new DateTime(msg.ReadInt64());
HandleGeneratorMessage(xGEN, yGEN, type, when);
break;
default:
Console.WriteLine("Unrecognized Game Message Recieved: {0}\n{1}", msg.ToString(), messageType);
break;
}
}
示例3: PeerConnected
private void PeerConnected(NetIncomingMessage message)
{
string connectionId = null;
if (message.SenderConnection.RemoteHailMessage != null)
connectionId = message.SenderConnection.RemoteHailMessage.ReadString();
if (connectionId == null)
{
ClientModel.Logger.WriteWarning("ConnectionId is null [Message: {0}, SenderEndPoint: {1}]", message.ToString(), message.SenderEndPoint);
return;
}
message.SenderConnection.Tag = connectionId;
lock (waitingCommands)
{
List<WaitingCommandContainer> commands;
if (waitingCommands.TryGetValue(connectionId, out commands))
{
foreach (WaitingCommandContainer command in commands)
SendMessage(connectionId, command.CommandId, command.MessageContent, command.Unreliable);
waitingCommands.Remove(connectionId);
}
}
ClientModel.Logger.WriteDebug("AsyncPeer.PeerConnected({0})", connectionId);
}