本文整理汇总了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;
}
}
示例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);
}
}
}
示例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);
}
}