本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.Reset方法的具体用法?C# NetIncomingMessage.Reset怎么用?C# NetIncomingMessage.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.Reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Recycle
/// <summary>
/// Recycles a NetIncomingMessage instance for reuse; taking pressure off the garbage collector
/// </summary>
public void Recycle(NetIncomingMessage msg)
{
if (m_incomingMessagesPool == null)
return;
NetException.Assert(m_incomingMessagesPool.Contains(msg) == false, "Recyling already recycled message! Thread race?");
byte[] storage = msg.m_data;
msg.m_data = null;
Recycle(storage);
msg.Reset();
m_incomingMessagesPool.Enqueue(msg);
}
示例2: Recycle
/// <summary>
/// Recycles a NetIncomingMessage instance for reuse; taking pressure off the garbage collector
/// </summary>
public void Recycle(NetIncomingMessage msg)
{
if (m_incomingMessagesPool == null)
return;
#if DEBUG
if (m_incomingMessagesPool.Contains(msg))
throw new NetException("Recyling already recycled message! Thread race?");
#endif
byte[] storage = msg.m_data;
msg.m_data = null;
Recycle(storage);
msg.Reset();
m_incomingMessagesPool.Enqueue(msg);
}
示例3: Update
//.........这里部分代码省略.........
//Only push updates for remote players...
if(playerid != ClientId)
player.Controller.PushUpdate(x, y, player.xVelocity, player.yVelocity, isShooting, triptime);
}
break;
case (byte)PacketTypes.EnemyAction:
{
int actionId = inc.ReadInt16();
float speed = inc.ReadFloat();
int seed = inc.ReadInt16();
EnemyManager.CrabCommand(actionId, speed, seed);
}
break;
case (byte)PacketTypes.EnemyHealth:
{
EnemyManager.CurrentHealth = inc.ReadInt16();
}
break;
case (byte)PacketTypes.PlayerHit:
{
int playerid = inc.ReadInt16();
if (Player==null||Player.Id == playerid)
break;
PlayerObject player = Players.Find(p => p.Id == playerid);
if (player!=null)
GameObject.Instantiate(Resources.Load("Detonator-Insanity"), player.Obj.transform.position, Quaternion.identity);
}
break;
default:
inc.Reset();
Debug.Log("Unhandled Packet Type Recieved. Packettype is " + Enum.GetName(typeof(PacketTypes), (int)inc.ReadByte()) + ".");
break;
}
}
break;
default:
break;
}
}
if (Time.time > lastSec+1)
{
lastSec=Time.time;
SendKeepAlive();
if (client.ConnectionStatus == NetConnectionStatus.Disconnected)
{
AddLobbyMessage("Lost connection to server. Attempting to reconnect...");
NetOutgoingMessage outmsg = new NetOutgoingMessage();
outmsg.Write("A Client");
IPAddress addr = (Dns.GetHostEntry(hostIp)).AddressList[0];
IPEndPoint ip = new IPEndPoint(addr,gm.gamePort);
NetConnection nc = client.GetConnection(ip);
if (nc !=null)
{
isConnected = false;
gm.isReady = false;
client.AcceptConnection(nc);
AddConsoleMessage("Lost connection to server. Attempting to reconnect...");
示例4: Update
//.........这里部分代码省略.........
}
break;
case (byte)PacketTypes.PlayerSpecial:
{
int playerid = inc.ReadInt16();
PlayerObject player = Players.Find(p => p.Id == playerid);
if (player == null)
break;
int specialType = inc.ReadInt16();
Debug.Log("Got special action request for player " + playerid);
if(playerid != ClientId)
player.Controller.UseSpecial(specialType);
}
break;
case (byte)PacketTypes.PlayerAction:
{
int playerid = inc.ReadInt16();
PlayerObject player = Players.Find(p => p.Id == playerid);
if (player == null)
break;
float x = inc.ReadFloat();
float y = inc.ReadFloat();
player.xVelocity = inc.ReadFloat();
player.yVelocity = inc.ReadFloat();
bool isShooting = inc.ReadBoolean();
float triptime = inc.ReadFloat() + roundtriptime;
//Only push updates for remote players...
if(playerid != ClientId)
player.Controller.PushUpdate(x, y, player.xVelocity, player.yVelocity, isShooting, triptime);
}
break;
case (byte)PacketTypes.EnemyAction:
{
int actionId = inc.ReadInt16();
float speed = inc.ReadFloat();
int seed = inc.ReadInt16();
EnemyManager.CrabCommand(actionId, speed, seed);
}
break;
case (byte)PacketTypes.EnemyHealth:
{
EnemyManager.CurrentHealth = inc.ReadInt16();
}
break;
case (byte)PacketTypes.PlayerHit:
{
int playerid = inc.ReadInt16();
if (Player.Id == playerid)
break;
PlayerObject player = Players.Find(p => p.Id == playerid);
GameObject.Instantiate(Resources.Load("Detonator-Insanity"), player.Obj.transform.position, Quaternion.identity);
}
break;
default:
inc.Reset();
Debug.Log("Unhandled Packet Type Recieved. Packettype is " + Enum.GetName(typeof(PacketTypes), (int)inc.ReadByte()) + ".");
break;
}
}
break;
default:
break;
}
}
if ((lastBeat + 10 < Time.time) || (lastBeat + 4 < Time.time && !isConnected))
{
if (isConnected)
{
AddConsoleMessage("Lost connection to server. Attempting to reconnect...");
isConnected = false;
isReady = false;
}
else
AddConsoleMessage("Attempting to connect to the server...");
NetOutgoingMessage outmsg = new NetOutgoingMessage();
outmsg.Write("A Client");
client.Connect(hostIp, 14248, outmsg);
lastBeat = Time.time;
}
}