本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadTime方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadTime方法的具体用法?C# NetIncomingMessage.ReadTime怎么用?C# NetIncomingMessage.ReadTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.ReadTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataProcessing
// TODO: Merge opcodes for move direction, something like that: Move(LookDirection)
void DataProcessing(NetIncomingMessage message, ref Client client)
{
switch (message.ReadByte())
{
case (byte)MessageType.ClientMessage.NeedMap:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Need map ! Let's give it to him :)");
ReceiveNeedMap(client);
break;
case (byte)MessageType.ClientMessage.MapSelection:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Has selected a map to play ! :)");
ReceiveMapSelection(client, message.ReadString());
break;
case (byte)MessageType.ClientMessage.Credentials:
ReceiveCredentials(client, message.ReadString(), message.ReadString());
break;
case (byte)MessageType.ClientMessage.Ready:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Ready message !");
ReceiveReady(client, message.ReadBoolean());
break;
case (byte)MessageType.ClientMessage.WantToStartGame:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] WantToStartGame message !");
ReceiveWantToStartGame();
break;
case (byte)MessageType.ClientMessage.HasMap:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] HasMap message !");
ReceiveHasMap(client);
break;
case (byte)MessageType.ClientMessage.MoveDown:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move down !");
ReceiveMovePlayer(client, LookDirection.Down);
break;
case (byte)MessageType.ClientMessage.MoveLeft:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move left !");
ReceiveMovePlayer(client, LookDirection.Left);
break;
case (byte)MessageType.ClientMessage.MoveRight:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move right !");
ReceiveMovePlayer(client, LookDirection.Right);
break;
case (byte)MessageType.ClientMessage.MoveUp:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to move up !");
ReceiveMovePlayer(client, LookDirection.Up);
break;
case (byte)MessageType.ClientMessage.Standing:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to stay here !");
ReceiveMovePlayer(client, LookDirection.Idle, message.ReadTime(client.ClientConnection, true));
break;
case (byte)MessageType.ClientMessage.PlaceBomb:
Program.Log.Info("[RECEIVE][Client #" + client.ClientId + "] Want to place bomb !");
ReceiveBombPlacing(client);
break;
}
}
示例2: ReadPlayerState
private void ReadPlayerState(NetIncomingMessage msg, Player p)
{
bool alive = msg.ReadBoolean();
if (alive)
{
float px = msg.ReadFloat();
float py = msg.ReadFloat();
bool moving = msg.ReadBoolean();
Direction direction = (Direction)msg.ReadByte();
float speed = msg.ReadFloat();
// player state
p.UpdateFromNetwork(px, py, moving, direction, speed);
// powerups
int powerupsCount = (int)Powerups.Count;
for (int i = 0; i < powerupsCount; ++i)
{
bool hasPower = msg.ReadBoolean();
if (hasPower)
{
int count = msg.ReadByte();
p.powerups.SetCount(i, count);
}
else
{
p.powerups.SetCount(i, 0);
}
}
// diseases
int diseasesCount = DiseaseList.diseaseArray.Length;
for (int i = 0; i < diseasesCount; ++i)
{
bool infected = msg.ReadBoolean();
if (infected)
{
float remains = (float)(msg.ReadTime(false) - NetTime.Now);
p.diseases.TryInfect(i);
p.diseases.SetInfectedRemains(i, remains);
}
else
{
p.diseases.TryCure(i);
}
}
}
else if (p.IsAlive)
{
Field.KillPlayer(p);
}
Bomb[] bombs = p.bombs.array;
for (int i = 0; i < bombs.Length; ++i)
{
ReadBombState(msg, p, bombs[i]);
}
}
示例3: ReadBombState
private void ReadBombState(NetIncomingMessage msg, Player p, Bomb b)
{
bool active = msg.ReadBoolean();
if (active)
{
float remains = (float)(msg.ReadTime(false) - NetTime.Now);
float px = msg.ReadFloat();
float py = msg.ReadFloat();
Direction dir = (Direction)msg.ReadByte();
float speed = msg.ReadFloat();
bool jelly = msg.ReadBoolean();
bool trigger = msg.ReadBoolean();
if (!b.isActive)
{
b.player = p;
b.Activate();
game.Field.SetBomb(b);
}
b.timeRemains = remains;
b.SetPos(px, py);
b.SetSpeed(speed);
b.SetJelly(jelly);
b.SetTrigger(trigger);
// TODO: jelly & trigger
}
else if (b.isActive)
{
b.Deactivate();
b.RemoveFromField();
}
}